<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>TechTips &#187; C#</title>
	<atom:link href="http://kshitijsharma.net/category/netaspnetvbnetcsql-server-mysql/net/c/feed/" rel="self" type="application/rss+xml" />
	<link>http://kshitijsharma.net</link>
	<description>.NET/ CSLA.NET / ASP.NET / VB.NET / C# / SQL Server / MySql / Android</description>
	<lastBuildDate>Wed, 12 Oct 2011 19:00:55 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Few facts about Abstract Classes (C#)</title>
		<link>http://kshitijsharma.net/2011/10/12/few-facts-about-abstract-classes-c/</link>
		<comments>http://kshitijsharma.net/2011/10/12/few-facts-about-abstract-classes-c/#comments</comments>
		<pubDate>Wed, 12 Oct 2011 18:51:41 +0000</pubDate>
		<dc:creator>Kshitij Sharma</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Technical]]></category>
		<category><![CDATA[VB.NET]]></category>

		<guid isPermaLink="false">http://kshitijsharma.net/?p=215</guid>
		<description><![CDATA[<blockquote>   <h1>&#160;</h1>    <h1>Hi friends.. I was having a discussion with few of my friends on different topics on OOPS. Just thought to put a post of some of the important facts which might help others as well.&#160; Starting with Abstract classes. Will be writing on more topics in next posts]]></description>
			<content:encoded><![CDATA[<blockquote><h1>&#160;</h1>
<h1>Hi friends.. sometime back I had a discussion with few of my friends on different topics on OOPS. Just thought to put a post of some of the important facts which might help others as well.&#160; Starting with Abstract classes. Will be writing on more topics in next posts.      <br />Abstract Classes</h1>
<h1></h1>
<h1></h1>
<h2></h2>
<ol>
<li>Abstract classes can have a non abstract ctor and they can’t be instantiated.</li>
<li>Since abstract classes can’t be instantiated one should not use <strong>Public</strong> and <strong>Protected Internal</strong> modifier with Abstract class Ctor.</li>
<li>Abstract class can be derived from a concrete class.</li>
<li>Abstract class can have non abstract members (methods, events, properties) but non abstract class can’t have abstract members.</li>
<li>An abstract class may contain abstract methods and accessors.</li>
<li>An abstract method is implicitly a virtual method.</li>
<li>Static and Virtual modifiers can’t be used with abstract methods</li>
<li>An abstract inherited property can be overridden in a derived class by including a property declaration that uses the override modifier. </li>
<li>Abstract classes can have concrete static methods.</li>
</ol>
<h1>Hope this helps..Please put your comments and any additional info about abstract class which may help others as well.</h1>
</blockquote>
<div id="st0000000001" class="st-taf"><script src="http://taf.socialtwist.com:80/taf/js/shoppr.core.js?id=0000000001"></script><img style="border:0;margin:0;padding:0;" src="http://tellafriend.socialtwist.com:80/wizard/images/tafbutton_blue16.png" onmouseout="hideHoverMap(this)" onmouseover="showHoverMap(this, '0000000001', 'http%3A%2F%2Fkshitijsharma.net%2F2011%2F10%2F12%2Ffew-facts-about-abstract-classes-c%2F', 'Few+facts+about+Abstract+Classes+%28C%23%29')" onclick="cw(this, {id:'0000000001',link: 'http%3A%2F%2Fkshitijsharma.net%2F2011%2F10%2F12%2Ffew-facts-about-abstract-classes-c%2F', title: '+Few+facts+about+Abstract+Classes+%28C%23%29+' })"/></div>]]></content:encoded>
			<wfw:commentRss>http://kshitijsharma.net/2011/10/12/few-facts-about-abstract-classes-c/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Difference between Const and Readonly</title>
		<link>http://kshitijsharma.net/2011/01/17/what-is-the-difference-between-const-and-readonly/</link>
		<comments>http://kshitijsharma.net/2011/01/17/what-is-the-difference-between-const-and-readonly/#comments</comments>
		<pubDate>Mon, 17 Jan 2011 09:51:39 +0000</pubDate>
		<dc:creator>Kshitij Sharma</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[C#]]></category>

		<guid isPermaLink="false">http://kshitijsharma.net/?p=179</guid>
		<description><![CDATA[Let's examine the difference between these two with an example code
<!--adsense#link_ad_horizontal-->
<br />

<a href="http://kshitijsharma.net/wp-content/uploads/2011/01/readonly_const.png"><img src="http://kshitijsharma.net/wp-content/uploads/2011/01/readonly_const.png" alt="" title="_readonly_const" width="441" height="298" class="alignnone size-full wp-image-195" /></a>

<br /><br />


]]></description>
			<content:encoded><![CDATA[<p><!-- chitika_500x250_Mega_Unit DISABLED--><br />
So what is the difference between CONST and READONLY? Let&#8217;s examine the difference between these two with an example.</p>
<p>
<a href="http://kshitijsharma.net/wp-content/uploads/2011/01/readonly_const.png"><img src="http://kshitijsharma.net/wp-content/uploads/2011/01/readonly_const.png" alt="" title="_readonly_const" width="441" height="298" class="alignnone size-full wp-image-195" /></a></p>
<p><!--adsense#link_ad_horizontal--><br />
So we can clearly see that we can initialize readonly variables during the declaration and in the constructor of the class. So its possible to initialize readonly variables once at run time but we can&#8217;t change value of const variables.</p>
<p>Happy coding!</p>
<div id="st0000000001" class="st-taf"><script src="http://taf.socialtwist.com:80/taf/js/shoppr.core.js?id=0000000001"></script><img style="border:0;margin:0;padding:0;" src="http://tellafriend.socialtwist.com:80/wizard/images/tafbutton_blue16.png" onmouseout="hideHoverMap(this)" onmouseover="showHoverMap(this, '0000000001', 'http%3A%2F%2Fkshitijsharma.net%2F2011%2F01%2F17%2Fwhat-is-the-difference-between-const-and-readonly%2F', 'Difference+between+Const+and+Readonly')" onclick="cw(this, {id:'0000000001',link: 'http%3A%2F%2Fkshitijsharma.net%2F2011%2F01%2F17%2Fwhat-is-the-difference-between-const-and-readonly%2F', title: '+Difference+between+Const+and+Readonly+' })"/></div>]]></content:encoded>
			<wfw:commentRss>http://kshitijsharma.net/2011/01/17/what-is-the-difference-between-const-and-readonly/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Showing Multiline string in a DataGridView Cell</title>
		<link>http://kshitijsharma.net/2010/08/23/showing-multiline-string-in-a-datagridview-cell/</link>
		<comments>http://kshitijsharma.net/2010/08/23/showing-multiline-string-in-a-datagridview-cell/#comments</comments>
		<pubDate>Mon, 23 Aug 2010 13:53:07 +0000</pubDate>
		<dc:creator>Kshitij Sharma</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[C#]]></category>

		<guid isPermaLink="false">http://kshitijsharma.net/?p=158</guid>
		<description><![CDATA[Hi,

Recently I need to show multi-line string in a datagridview cell. To achieve that we need to write code in CellFormatting event of DataGridview. Following is the code]]></description>
			<content:encoded><![CDATA[<p>Hi,</p>
<p>Recently I need to show multi-line string in a datagridview cell. To achieve that we need to write code in CellFormatting event of DataGridview. Following is the code</p>
<pre class="brush: csharp; title: ; notranslate">
private void dataGridView1_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
        {
            if (e.Value.Equals(&quot;Error&quot;))
            {
                e.CellStyle.BackColor = Color.Red;
                e.CellStyle.ForeColor = Color.White;

            }
            else
            {
                if ((!e.Value.Equals(&quot;OK&quot;)) &amp;&amp; e.ColumnIndex==2)
                {
                    e.CellStyle.BackColor = Color.Green;
                    e.CellStyle.ForeColor = Color.White;
                    e.CellStyle.WrapMode = DataGridViewTriState.True;
                    dataGridView1.Columns[2].AutoSizeMode = DataGridViewAutoSizeColumnMode.DisplayedCells;
                    dataGridView1.AutoSizeRowsMode = DataGridViewAutoSizeRowsMode.AllCells;

                }

            }
        }
</pre>
<p>I hope this help!</p>
<p>Kshitij</p>
<div id="st0000000001" class="st-taf"><script src="http://taf.socialtwist.com:80/taf/js/shoppr.core.js?id=0000000001"></script><img style="border:0;margin:0;padding:0;" src="http://tellafriend.socialtwist.com:80/wizard/images/tafbutton_blue16.png" onmouseout="hideHoverMap(this)" onmouseover="showHoverMap(this, '0000000001', 'http%3A%2F%2Fkshitijsharma.net%2F2010%2F08%2F23%2Fshowing-multiline-string-in-a-datagridview-cell%2F', 'Showing+Multiline+string+in+a+DataGridView+Cell')" onclick="cw(this, {id:'0000000001',link: 'http%3A%2F%2Fkshitijsharma.net%2F2010%2F08%2F23%2Fshowing-multiline-string-in-a-datagridview-cell%2F', title: '+Showing+Multiline+string+in+a+DataGridView+Cell+' })"/></div>]]></content:encoded>
			<wfw:commentRss>http://kshitijsharma.net/2010/08/23/showing-multiline-string-in-a-datagridview-cell/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Add text to the beginning of a file using C#</title>
		<link>http://kshitijsharma.net/2009/12/08/add-text-to-the-beginning-of-a-file-using-c/</link>
		<comments>http://kshitijsharma.net/2009/12/08/add-text-to-the-beginning-of-a-file-using-c/#comments</comments>
		<pubDate>Tue, 08 Dec 2009 11:18:53 +0000</pubDate>
		<dc:creator>Kshitij Sharma</dc:creator>
				<category><![CDATA[C#]]></category>

		<guid isPermaLink="false">http://kshitijsharma.net/?p=136</guid>
		<description><![CDATA[Hi,

Few days back i needed a code snippet to write a text in starting of all files in a directory. Searched net but could not find any working code. Then i decide to write my own code and come up with following code. I hope ]]></description>
			<content:encoded><![CDATA[<p><!-- chitika_500x250_Mega_Unit DISABLED--></p>
<p>Hi,</p>
<p>Few days back i needed a code snippet to write a text in starting of all files in a directory. Searched net but could not find any working code. Then i decide to write my own code and come up with following code.<br />
<!--adsense#link_ad_horizontal--><br />
I hope this will help guys who are looking to do same.</p>
<pre class="brush: csharp; title: ; notranslate">
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

namespace AddTextToFiles
{
    class Program
    {
        private static DirectoryInfo ds;
        static void Main(string[] args)
        {
            Console.WriteLine(&quot;*********************Written By Kshitij Sharma ***********************&quot;);
            Console.WriteLine(&quot;Please Enter the path and Press enter &quot;);
            string sPath = Console.ReadLine();
            Console.WriteLine(&quot;Please Enter &lt;B style=&quot;BACKGROUND-COLOR: #a0ffff; COLOR: black&quot;&gt;Text&lt;/B&gt; &quot;);
            string sText = Console.ReadLine();
            addText(sPath,sText);
            Console.WriteLine(&quot;*****************Reach Me @ k.sharma78@gmail.com****************&quot;);
            Console.Read();
        }

        private static void addText(string pth,string txt)
        {
            try
            {

                if (!string.IsNullOrEmpty(pth))
                {
                    ds = new DirectoryInfo(pth);
                }
                else
                {
                    ds = new DirectoryInfo(&quot;c:\\testfiles&quot;);
                }
                if (string.IsNullOrEmpty(txt))
                {
                    txt = &quot;&lt;!--#Include File=\&quot;CheckSQL.inc\&quot;--&gt;&quot;;
                }
                foreach (FileInfo f in ds.GetFiles(&quot;*.asp&quot;))
                {
                    Console.WriteLine(&quot;Writing to file--&gt;&quot; + f.Name);
                    string strPath = ds.Root + ds.Name + &quot;\\&quot; + f.Name;
                    StreamReader sr = new StreamReader(strPath);
                    string fileContent = sr.ReadToEnd();
                    sr.Close();
                    StreamWriter sw = new StreamWriter(strPath, false);
                    StringReader gr = new StringReader(fileContent);
                    sw.WriteLine(txt);
                    sw.WriteLine(gr.ReadToEnd());
                    sw.Close();
                }
            }
            catch(Exception ex)
            {
                Console.WriteLine(ex.Message);
                Console.Read();
            }
        }
    }
}
</pre>
<div id="st0000000001" class="st-taf"><script src="http://taf.socialtwist.com:80/taf/js/shoppr.core.js?id=0000000001"></script><img style="border:0;margin:0;padding:0;" src="http://tellafriend.socialtwist.com:80/wizard/images/tafbutton_blue16.png" onmouseout="hideHoverMap(this)" onmouseover="showHoverMap(this, '0000000001', 'http%3A%2F%2Fkshitijsharma.net%2F2009%2F12%2F08%2Fadd-text-to-the-beginning-of-a-file-using-c%2F', 'Add+text+to+the+beginning+of+a+file+using+C%23')" onclick="cw(this, {id:'0000000001',link: 'http%3A%2F%2Fkshitijsharma.net%2F2009%2F12%2F08%2Fadd-text-to-the-beginning-of-a-file-using-c%2F', title: '+Add+text+to+the+beginning+of+a+file+using+C%23+' })"/></div>]]></content:encoded>
			<wfw:commentRss>http://kshitijsharma.net/2009/12/08/add-text-to-the-beginning-of-a-file-using-c/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

