<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:pingback="http://madskills.com/public/xml/rss/module/pingback/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:dc="http://purl.org/dc/elements/1.1/" version="2.0">
  <channel>
    <title>Rajan's Blog - .NET</title>
    <link>http://blog.rajan.net.in/</link>
    <description>Experience Talks</description>
    <language>en-us</language>
    <copyright>Rajan R.G</copyright>
    <lastBuildDate>Fri, 02 Oct 2009 13:49:13 GMT</lastBuildDate>
    <generator>newtelligence dasBlog 2.3.9074.18820</generator>
    <managingEditor>rgrajan@gmail.com</managingEditor>
    <webMaster>rgrajan@gmail.com</webMaster>
    <item>
      <trackback:ping>http://blog.rajan.net.in/Trackback.aspx?guid=38a093c5-5a49-4d7a-99d9-c6427d09daa8</trackback:ping>
      <pingback:server>http://blog.rajan.net.in/pingback.aspx</pingback:server>
      <pingback:target>http://blog.rajan.net.in/PermaLink,guid,38a093c5-5a49-4d7a-99d9-c6427d09daa8.aspx</pingback:target>
      <dc:creator>Rajan R.G</dc:creator>
      <wfw:comment>http://blog.rajan.net.in/CommentView,guid,38a093c5-5a49-4d7a-99d9-c6427d09daa8.aspx</wfw:comment>
      <wfw:commentRss>http://blog.rajan.net.in/SyndicationService.asmx/GetEntryCommentsRss?guid=38a093c5-5a49-4d7a-99d9-c6427d09daa8</wfw:commentRss>
      <slash:comments>1</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
I hope the .NET developers are enjoying with C# 3.0 lambda expressions. This is one
of the easiest way for removing items from the generic list object based on a condition.
</p>
        <p>
_sessionList.RemoveAll(x =&gt; x.MarkforRemoval == true);
</p>
        <p>
The above code removes all the items marked for removal. This also avoid the error
“Collection was modified; enumeration operation may not execute” if you are checking
the conditions in the foreach loop and removing it.
</p>
        <p>
Quick snippet, hopefully useful.
</p>
        <img width="0" height="0" src="http://blog.rajan.net.in/aggbug.ashx?id=38a093c5-5a49-4d7a-99d9-c6427d09daa8" />
      </body>
      <title>How to Remove items from generic List with condition</title>
      <guid isPermaLink="false">http://blog.rajan.net.in/PermaLink,guid,38a093c5-5a49-4d7a-99d9-c6427d09daa8.aspx</guid>
      <link>http://blog.rajan.net.in/2009/10/02/HowToRemoveItemsFromGenericListWithCondition.aspx</link>
      <pubDate>Fri, 02 Oct 2009 13:49:13 GMT</pubDate>
      <description>&lt;p&gt;
I hope the .NET developers are enjoying with C# 3.0 lambda expressions. This is one
of the easiest way for removing items from the generic list object based on a condition.
&lt;/p&gt;
&lt;p&gt;
_sessionList.RemoveAll(x =&amp;gt; x.MarkforRemoval == true);
&lt;/p&gt;
&lt;p&gt;
The above code removes all the items marked for removal. This also avoid the error
“Collection was modified; enumeration operation may not execute” if you are checking
the conditions in the foreach loop and removing it.
&lt;/p&gt;
&lt;p&gt;
Quick snippet, hopefully useful.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://blog.rajan.net.in/aggbug.ashx?id=38a093c5-5a49-4d7a-99d9-c6427d09daa8" /&gt;</description>
      <comments>http://blog.rajan.net.in/CommentView,guid,38a093c5-5a49-4d7a-99d9-c6427d09daa8.aspx</comments>
      <category>.NET</category>
    </item>
    <item>
      <trackback:ping>http://blog.rajan.net.in/Trackback.aspx?guid=43ef0f23-32fa-4858-ae8b-f4d70e1ec911</trackback:ping>
      <pingback:server>http://blog.rajan.net.in/pingback.aspx</pingback:server>
      <pingback:target>http://blog.rajan.net.in/PermaLink,guid,43ef0f23-32fa-4858-ae8b-f4d70e1ec911.aspx</pingback:target>
      <dc:creator>Rajan R.G</dc:creator>
      <wfw:comment>http://blog.rajan.net.in/CommentView,guid,43ef0f23-32fa-4858-ae8b-f4d70e1ec911.aspx</wfw:comment>
      <wfw:commentRss>http://blog.rajan.net.in/SyndicationService.asmx/GetEntryCommentsRss?guid=43ef0f23-32fa-4858-ae8b-f4d70e1ec911</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
It is very easy to format the datetime to string in .NET and this is commonly used
by the developers while displaying the date &amp; time in desired format. But if you
would like to store the formatted value in datetime variable, the value changes according
to the .NET default format.
</p>
        <p>
Default datetime format in .NET is
</p>
        <p>
          <a href="http://blog.rajan.net.in/content/binary/WindowsLiveWriter/C.NETHowtoformatdatetimeandstoreindateti_A35B/image_4.png">
            <img style="border-bottom: 0px; border-left: 0px; border-top: 0px; border-right: 0px" border="0" alt="image" src="http://blog.rajan.net.in/content/binary/WindowsLiveWriter/C.NETHowtoformatdatetimeandstoreindateti_A35B/image_thumb_1.png" width="244" height="43" />
          </a>
        </p>
        <p>
We will try this to format the value,
</p>
        <p>
          <a href="http://blog.rajan.net.in/content/binary/WindowsLiveWriter/C.NETHowtoformatdatetimeandstoreindateti_A35B/image_6.png">
            <img style="border-bottom: 0px; border-left: 0px; border-top: 0px; border-right: 0px" border="0" alt="image" src="http://blog.rajan.net.in/content/binary/WindowsLiveWriter/C.NETHowtoformatdatetimeandstoreindateti_A35B/image_thumb_2.png" width="244" height="34" />
          </a>
        </p>
        <p>
When we try to assign the formatted value to a datetime variable the format again
changed to default format
</p>
        <p>
          <a href="http://blog.rajan.net.in/content/binary/WindowsLiveWriter/C.NETHowtoformatdatetimeandstoreindateti_A35B/image_8.png">
            <img style="border-bottom: 0px; border-left: 0px; border-top: 0px; border-right: 0px" border="0" alt="image" src="http://blog.rajan.net.in/content/binary/WindowsLiveWriter/C.NETHowtoformatdatetimeandstoreindateti_A35B/image_thumb_3.png" width="244" height="40" />
          </a>
        </p>
        <p>
To avoid this, use DateTime.ParseExact
</p>
        <pre class="brush: csharp; ruler: true; gutter: false; auto-links: false;">DateTime dt = DateTime.ParseExact(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff"), "yyyy-MM-dd HH:mm:ss.fff", CultureInfo.InvariantCulture);</pre>
        <p>
Where is this useful? 
<br />
If you develop client server application the .NET stores the datetime value with timezone.
The above syntax is timezone free, which will be useful across the application.
</p>
        <p>
Also refer this link for DateTime best practices <a title="http://msdn.microsoft.com/en-us/library/ms973825.aspx" href="http://msdn.microsoft.com/en-us/library/ms973825.aspx">http://msdn.microsoft.com/en-us/library/ms973825.aspx</a></p>
        <img width="0" height="0" src="http://blog.rajan.net.in/aggbug.ashx?id=43ef0f23-32fa-4858-ae8b-f4d70e1ec911" />
      </body>
      <title>C#.NET How to format datetime and store in datetime variable</title>
      <guid isPermaLink="false">http://blog.rajan.net.in/PermaLink,guid,43ef0f23-32fa-4858-ae8b-f4d70e1ec911.aspx</guid>
      <link>http://blog.rajan.net.in/2009/05/01/CNETHowToFormatDatetimeAndStoreInDatetimeVariable.aspx</link>
      <pubDate>Fri, 01 May 2009 06:07:10 GMT</pubDate>
      <description>&lt;p&gt;
It is very easy to format the datetime to string in .NET and this is commonly used
by the developers while displaying the date &amp;amp; time in desired format. But if you
would like to store the formatted value in datetime variable, the value changes according
to the .NET default format.
&lt;/p&gt;
&lt;p&gt;
Default datetime format in .NET is
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://blog.rajan.net.in/content/binary/WindowsLiveWriter/C.NETHowtoformatdatetimeandstoreindateti_A35B/image_4.png"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; border-top: 0px; border-right: 0px" border="0" alt="image" src="http://blog.rajan.net.in/content/binary/WindowsLiveWriter/C.NETHowtoformatdatetimeandstoreindateti_A35B/image_thumb_1.png" width="244" height="43" /&gt;&lt;/a&gt; 
&lt;/p&gt;
&lt;p&gt;
We will try this to format the value,
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://blog.rajan.net.in/content/binary/WindowsLiveWriter/C.NETHowtoformatdatetimeandstoreindateti_A35B/image_6.png"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; border-top: 0px; border-right: 0px" border="0" alt="image" src="http://blog.rajan.net.in/content/binary/WindowsLiveWriter/C.NETHowtoformatdatetimeandstoreindateti_A35B/image_thumb_2.png" width="244" height="34" /&gt;&lt;/a&gt; 
&lt;/p&gt;
&lt;p&gt;
When we try to assign the formatted value to a datetime variable the format again
changed to default format
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://blog.rajan.net.in/content/binary/WindowsLiveWriter/C.NETHowtoformatdatetimeandstoreindateti_A35B/image_8.png"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; border-top: 0px; border-right: 0px" border="0" alt="image" src="http://blog.rajan.net.in/content/binary/WindowsLiveWriter/C.NETHowtoformatdatetimeandstoreindateti_A35B/image_thumb_3.png" width="244" height="40" /&gt;&lt;/a&gt; 
&lt;/p&gt;
&lt;p&gt;
To avoid this, use DateTime.ParseExact
&lt;/p&gt;
&lt;pre class="brush: csharp; ruler: true; gutter: false; auto-links: false;"&gt;DateTime dt = DateTime.ParseExact(DateTime.Now.ToString(&amp;quot;yyyy-MM-dd HH:mm:ss.fff&amp;quot;), &amp;quot;yyyy-MM-dd HH:mm:ss.fff&amp;quot;, CultureInfo.InvariantCulture);&lt;/pre&gt;
&lt;p&gt;
Where is this useful? 
&lt;br /&gt;
If you develop client server application the .NET stores the datetime value with timezone.
The above syntax is timezone free, which will be useful across the application.
&lt;/p&gt;
&lt;p&gt;
Also refer this link for DateTime best practices &lt;a title="http://msdn.microsoft.com/en-us/library/ms973825.aspx" href="http://msdn.microsoft.com/en-us/library/ms973825.aspx"&gt;http://msdn.microsoft.com/en-us/library/ms973825.aspx&lt;/a&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://blog.rajan.net.in/aggbug.ashx?id=43ef0f23-32fa-4858-ae8b-f4d70e1ec911" /&gt;</description>
      <comments>http://blog.rajan.net.in/CommentView,guid,43ef0f23-32fa-4858-ae8b-f4d70e1ec911.aspx</comments>
      <category>.NET</category>
    </item>
  </channel>
</rss>