Welcome to MSDN Blogs Sign in | Join | Help

April 2006 - Posts

SYSK 115: Do You Know When and How to Use TypeForwardedTo Attribute?

Do you remember the old TreatAs registry setting for COM classes? If you want a quick refresher, check out http://msdn.microsoft.com/library/default.asp?url=/library/en-us/com/html/1d7a1677-738a-4258-9afc-e77bd0dcf40f.asp . Well, TypeForwardedTo attribute
Posted by irenak | 0 Comments

SYSK 114: String Interning

What do you think is the value of variable result in the code below: string x = "some string here"; bool result = Object.ReferenceEquals("some string here", x); Given that the data type string is a reference type, it may come as a surprise to some, that
Posted by irenak | 2 Comments

SYSK 113: System.Convert.ChangeType Undercover

Are you curious about how ChangeType is implemented, and whether it is different from a cast? Then read on… First, what is a cast? C# allows classes and structures to create operators that convert the underlying data type to another type. Conversions
Posted by irenak | 2 Comments

SYSK 112: How to Invoke a Method on the Parent Web Form From a Control

The other day I was asked the question above, and since others might benefit from seeing the answer, and I’m sharing it with SYSK readers below. Question: I've a need to call a method on a WebForm from within the UserControl that lives on that form. Here's
Posted by irenak | 0 Comments

SYSK 111: RoundUp and RoundDown in .NET with Decimal Digits

Excel has two very important functions – CEILING and FLOOR that take in two parameters – number and significance. For example, the CEILING function returns number rounded up to the nearest multiple of significance. For example, if you want to avoid using
Posted by irenak | 0 Comments

SYSK 110: Two-Key Dictionary Class

The other day I needed to have a dictionary (i.e. fast search by key) class that works on two keys. This is somewhat akin to a three level tree structure -- first level has elements specified by first key, second level – by second key, and the final third
Posted by irenak | 1 Comments

SYSK 109: Is it possible to change the ForeColor of a SubItem in a ListView?

The other day I came across the question above at http://www.codecomments.com/archive293-2004-7-244806.html , which did not provide the way to accomplish the desired effect. The answer is – yes, you can. Here is how you might go above doing it in .NET
Posted by irenak | 0 Comments

SYSK 108: What is XPS?

XPS stands for XML Paper Specification – a specification is designed to provide users with a consistent document appearance regardless of where and how the document is viewed, and will be implemented in Windows Vista™. XPS Documents are fixed-format documents
Posted by irenak | 1 Comments

SYSK 107: The Difference Between Decimal.ToString(“C”) and Decimal.ToString(“C2”)

Formatting string “C2” explicitly tells to leave two decimals. One could also use “C0” (no decimals), “C1”, “C3”, “C4”. Many believe that there is no difference between the format strings “C” and C2”. While it’s true in the default scenario, it’s only
Posted by irenak | 0 Comments

SYSK 106: The Cost of Using WindowsPrincipal

Did you know that using WindowsPrincipal.IsInRole is ~40+% slower than doing the same work yourself? Run the code below and you’ll see … Don’t take me wrong – I do not suggest you avoid using IsInRole call; after all a single call is so fast on most computers
Posted by irenak | 6 Comments

SYSK 105: Switching Between Running ASP.NET Project Under IIS and Personal Web Server

As you know, in VS 2005 you can choose “File System” location option when creating an ASP.NET project. Once selected, how do you switch to running your project as a “normal” IIS web site? The solution is simple: Create a virtual directory in IIS (or,
Posted by irenak | 0 Comments

SYSK 104: Great Tool for ASP.NET developers

Would you like to view items stored in cache, and remove them for testing purposes? How about being able to view the page's view state (in various forms: raw, parsed, and decoded) to help you optimize your state management logic? Does ability to hide
Posted by irenak | 0 Comments

SYSK 103: WriteFile or TransmitFile?

Both, HttpResponse.WriteFile and HttpResponse.TransmitFile (new in 2.0) write the contents of a file to the output stream. However, WriteFile will load the whole file into the memory while TransmitFile won’t. So, if you’ve been using WriteFile, you may
Posted by irenak | 6 Comments

SYSK 102: Unexpected Behavior in Generics

Consider the following: static public class MyClass { static public void Method<T>(T x) { . . . MethodX(x); . . . } static private void MethodX(float x) { System.Diagnostics.Debug.WriteLine("Float"); } static private void MethodX(object x) { System.Diagnostics.Debug.WriteLine("Object");
Posted by irenak | 4 Comments

SYSK 101: How to Release Build an ASP.NET application

You may have noticed that there is no release build option for web apps. That’s because all compilation settings are now stored in the <compilation> element of your configuration file under <system.web>. Set debug attribute to false for release
Posted by irenak | 2 Comments

SYSK 100: Can You Define What Is Web 2.0?

If not, there is a very good explanation at http://en.wikipedia.org/wiki/Web_2.0 . Here are some main points: To some extent Web 2.0 is a buzzword, incorporating whatever is newly popular on the Web (such as tags and podcasts), and its meaning is still
Posted by irenak | 0 Comments

SYSK 99: Is [MTAThread] the Only Solution?

By default, Windows apps (WinForms) are marked with STAThread attribute (see Program.cs). So, if you call System.Threading.WaitHandle.WaitAll passing more than one handle in the array you’ll get an exception “WaitAll for multiple handles on an STA thread
Posted by irenak | 2 Comments

SYSK 98: Digging Deeper Into GetHashCode

So, you think you understand when, how and why to override GetHashCode? Then you should be able to answer the following question: will get message box in the code below say “true” or “false”: public class MyClass { private string _param; public string
Posted by irenak | 4 Comments

SYSK 97: The Power of Environmental Variables

Did you know that if you type %appdata% in Windows Explorer’s address bar, and press Enter, it’ll open C:\Documents and Settings\UserName\Application Data folder? Likewise, by typing %windir%, you’ll get into whatever folder you’ve installed windows (e.g.
Posted by irenak | 0 Comments

SYSK 96: Macros to Expand and Collapse Regions in VS.NET

Unquestionably, regions make code much cleaner! But they also led to an explosion of method sizes (in number of lines) and the number of methods per file. Long gone is the “rule of thumb” of early 90s of a function size being equal to the visible screen
Posted by irenak | 0 Comments
 
Page view tracker