Odd or Even? (C#)

by Vitaly Zayko 24. February 2010 21:15

How to quickly determine is given number odd or even? There are several simple methods.

Here is the first one:

 

 public bool IsEven(int i)
 {
     return (i & 1) == 0;
 }

And the second:

 public bool IsEven(int i)
 {
     return (i % 2) == 0;
 }

 

Technorati Tags:
Digg It!DZone It!StumbleUponTechnoratiRedditDel.icio.usNewsVineFurlBlinkList

Tags:

Code Snippets

Announced Visual Studio 2010 launch date!

by Vitaly Zayko 15. January 2010 18:49

And it will be April 12, 2010.

BTW: April 12 is Space Day in Russia: 12 April 1961 Yuri Gagarin became first man on Earth orbit.

Digg It!DZone It!StumbleUponTechnoratiRedditDel.icio.usNewsVineFurlBlinkList

Tags:

General

God Mode on Windows 7

by Vitaly Zayko 6. January 2010 06:22

Recently taken from here.

Do you want to keep all Windows 7 settings in one simple place? Then create an empty folder on your desktop and rename it to GodMode.{ED7BA470-8E54-465E-825C-99712043E01C}. Amazing!

Digg It!DZone It!StumbleUponTechnoratiRedditDel.icio.usNewsVineFurlBlinkList

Tags:

General

Another way to get path to a running assembly or how to get list of command line arguments in a non console App?

by Vitaly Zayko 23. December 2009 16:58

There is an another way how to get path to a running assembly from itself besides I mentioned here. Use this simple snippet:

string[] cmd = Environment.GetCommandLineArgs();
string path_to_assembly = cmd[0];
/* cmd[1] and above contains command line arguments is any */

Resulting array is at least one element length or longer. First element of this array always contains path to the assembly. As a side effect – you can get command line params beginning from second element.

Unfortunately doesn’t work in .NET Compact Framework.

Technorati Tags: ,
Digg It!DZone It!StumbleUponTechnoratiRedditDel.icio.usNewsVineFurlBlinkList

Tags:

Code Snippets

Adding /r/n in .NET (C#)

by Vitaly Zayko 30. November 2009 16:05

When your App outputs some text, you probably will want to split your strings by adding carriage return. Of course, you can declare this as a constant string: private const string CRLF = "/r/n";

or use predefined constant from Environment: Environment.NewLine

Digg It!DZone It!StumbleUponTechnoratiRedditDel.icio.usNewsVineFurlBlinkList

Tags:

Code Snippets

Using Windows 7 Jump List in Visual Studio 2010 Beta 2

by Vitaly Zayko 2. November 2009 20:48

If you are on Windows 7, you probably have noticed about new feature – Windows 7 Jump List. If you right-click on an App icon (let say – Internet Explorer) you will see additional menu items which you as a programmer can handle in your solutions. If you are on Visual Studio 2008, the only way is to use an additional Windows API Code Pack for Microsoft .NET Framework. But there is a modern way for Visual Studio 2010 (at least for WPF):

  • Open App.xaml file of your App
  • Add reference to JumpList as shown below:

<Application x:Class="WpfApplication1.App"

             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"

             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"

             StartupUri="MainWindow.xaml">

    <Application.Resources>    

    </Application.Resources>

    <!-- Add reference to JumpList here: -->

    <JumpList.JumpList>

        <JumpList ShowFrequentCategory="True" ShowRecentCategory="True">

            <JumpTask Title="Notepad"

                      Description="Open Notepad"

                      ApplicationPath="notepad.exe"

                      IconResourcePath="notepad.exe"/>

        </JumpList>

    </JumpList.JumpList>

</Application>

Technorati Tags: ,,
Digg It!DZone It!StumbleUponTechnoratiRedditDel.icio.usNewsVineFurlBlinkList

Tags: , ,

Code Snippets | Visual Studio Tip

Microsoft Visual Studio 2010 Beta 2 is available for MSDN Subscribers!

by Vitaly Zayko 19. October 2009 21:21

VS_v_rgb_ai If you are lucky MSDN Subscriber, you can download VS2010 as well as TFS2010 right now! I already did.
BTW: TFS2010 has "go live" license which means you can use it in your daily work instead of just testing purposes. Here are more details: Brian Keller's blog.
If you don't have the subscription, you just need little wait - it will be available for everyone in October 22nd.

Technorati Tags:
Digg It!DZone It!StumbleUponTechnoratiRedditDel.icio.usNewsVineFurlBlinkList

Tags:

General

Most useful Windows 7 shortcut keys

by Vitaly Zayko 22. September 2009 11:46

I’m a happy MSDN subscriber so have Windows 7 installed for few months by now and got some useful shortcuts to share.

  • Multi monitor system? Use Win+Shift+Left to move to the left monitor or Win+Shift+Right – to the right
  • Win+P – switches between monitor options (multi monitor/projector settings)
  • One monitor? Then Win+Left is snapping current window to the left side and Win+Right – to the right
  • Win+Space – peeks at the Desktop
  • Win+X – calls Mobility Center
  • Win+T – first Taskbar entry
  • Win+G – brings desktop gadgets to the top

Enjoy!

Technorati Tags:
Digg It!DZone It!StumbleUponTechnoratiRedditDel.icio.usNewsVineFurlBlinkList

Tags:

General

How to boot Windows 7 faster?

by Vitaly Zayko 4. September 2009 12:54

Check your system configuration: active services, what items run at startup ect. All of those are in one place: MSCONFIG.

MSCONFIG in Microsoft Windows 7

Technorati Tags:
Digg It!DZone It!StumbleUponTechnoratiRedditDel.icio.usNewsVineFurlBlinkList

Tags:

General

How to enable menu “Create GUID” in Visual Studio 2008

by Vitaly Zayko 29. July 2009 18:05

If you need to create a GUID in VS2008 but this menu is disabled then you are facing the same problem as I did. Probably some options were disabled during installation. Fortunately it is easy to fix.

Copy two files guidgen.exe and Uuidgen.Exe form
C:\Program Files\Microsoft SDKs\Windows\v6.0A\bin
to
C:\Program Files\Microsoft Visual Studio 9.0\Common7\Tools
and you don’t even need to restart your Visual Studio.

Digg It!DZone It!StumbleUponTechnoratiRedditDel.icio.usNewsVineFurlBlinkList

Tags:

Visual Studio Tip

Powered by BlogEngine.NET 1.5.0.7
Theme by Mads Kristensen

Calendar

<<  March 2010  >>
MoTuWeThFrSaSu
22232425262728
1234567
891011121314
15161718192021
22232425262728
2930311234

View posts in large calendar

About the author

Vitaly Zayko

Senior Software Developer / Team Lead / Product Manager

Moscow, Russia