Manish Pansiniya's Blog

.NET, C#, Javascript, ASP.NET and lots more…:)

Posts Tagged ‘C#

Custom Format Specify in DateTime Format String C#

with one comment

Whenever we specify / in the DateTime format, it shows and convert the DateTime Separator that is setup in your regional settings.

so DateTime.Now.Date.ToString(@"d/MM/yyyy") will display “3-06-2010” on my pc as my regional setting has “–” as datetime separator.

If you require / in the date (or if you need any char as it is without converting it to Format specified in DateTime) then you need to add escape char before the char you require.

And that is the reason, DateTime.Now.Date.ToString(@"d\/MM\/yyyy") will give you “3/06/2010”

🙂 Happy ProgRaMMing

Advertisements

Written by Manish

June 3, 2010 at 4:31 pm

Ways to clear stringbuilder in C#

with 2 comments

There are no clear method straightaway to clear the string stored in stringbuilder class.

So there are alternatives to do that.

sbObject.Remove(0,sbObject.Length);

or you can do the below also

string strObject= sbObject.ToString();
sbObject.Replace(strObject,"");

 
But Microsoft people woken up and put the Clear() function in .NET 4.0 🙂
 

Written by Manish

February 6, 2010 at 11:08 am

Posted in .NET

Tagged with , ,

ThreadManager (C# Threading class) is now on CodePlex

leave a comment »

 

I have uploaded ThreadManager class as new project on CodePlex. So it can be downloaded and used from there. It is really simple class to use with threadpool implementation. Already tested!!! :). Following is the URL

http://threadmanager.codeplex.com/

There are other projects for Threading on CodePlex website. You can search using ‘Threading’ and get the same.

EnJoY!!! ::):)

Written by Manish

April 7, 2009 at 6:30 pm