Category: C Sharp(C#)

  • Do try...catch blocks hurt runtime performance?

    Recently, a friend mentioned that someone had told him that writing a try...catch block in C# (or substitute some other .Net language here) resulted in a " huge penalty " in terms of performance compared to if you had not written it. That is, merely writing such a block actually hurt program performance, even if an exception was never thrown. He didn't believe this was true, and rightly so - it's completely wrong. This post is a tidied up...>
    Read more...
    2/25/2008 12:55:59 AM Published by FengLiN Category C Sharp(C#) Comments 0 Views (624)
  • Using C# To Extract Icons from any Files

    Have you ever seen a file with a pretty icon you wanted to use but you couldn't get a similar one in your program? If yes, try this method >> Icon.ExtractAssociatedIcon here is the code I wrote that works fine, you will also find the sample attached Icon ico; public Form1() { InitializeComponent(); ico = this.Icon; } private void btnGetIcon_Click(object sender, EventArgs e) { if(dlgOpen.ShowDialog() ==...>
    Read more...
    2/25/2008 12:47:00 AM Published by FengLiN Category C Sharp(C#) Comments 0 Views (675)
  • What's new in C# 3.0

    In this article, I will cover at a glance the new features of C# 3.0. I have been working with this new development environment for several days and want to share my experience with you Implicit typed local variables Local variables can be declared as type var, whose actual type of the variable is determined by the compiler based on the data schema (see Listing 1). It's mainly used to store anonymous types in LINQ.  ...>
    Read more...
    2/13/2008 10:26:00 PM Published by FengLiN Category C Sharp(C#) Comments 0 Views (711)
  • the "Using" statement in C#

    1. using + namespace: So you can use the type under the namespace directly, without type in the full namespace name. similar with Jave's Import. Example: using System.Data; 2. using + Alias Name = full type name. when to use: You can use this when you using 2 different namespaces in 1 cs file. but these 2 different namespaces contains a type with same name. example: using aClass = NameSpace1.MyClass; using bClass = NameSpace2.MyClass;...>
    Read more...
    2/5/2008 3:51:23 AM Published by FengLiN Category C Sharp(C#) Comments 0 Views (770)
  • How To Use: System.IO.FileSystemWatcher to monitor the files

    Today I will talk about the " System.IO.FileSystemWatcher". It allows you to be notified when a file or directory (folder) has been created, renamed, changed or deleted. You can even sit and wait for such an activity to take place. Ok, Let me show you how to use this class. 1. Create a new object of FileSystemWatcher. System.IO.FileSystemWatcher fswXmlFileWatcher = new System.IO.FileSystemWatcher(); this.fswXmlFileWatcher.EnableRaisingEvents...>
    Read more...
    1/30/2008 1:37:00 AM Published by FengLiN Category C Sharp(C#) Comments 0 Views (1243)