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;
}
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.
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!
608741c6-4eff-4dc4-af3d-2adecdd019f7|1|5.0
Tags: win7
General
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:
C#,
.Net Framework
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
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:
VS2010Tips,
WPF,
Win7
by Vitaly Zayko
19. October 2009 21:21
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.
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!
815e87e2-2c41-4a0c-807e-6e761566804f|0|.0
Tags: win7
General
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.
6c9dec50-f28b-479d-b761-85cd8f49075c|2|4.0
Tags: win7
General
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.