tag:blogger.com,1999:blog-64277037637855253122024-02-19T14:31:05.612-08:00Microsoft C#.Net Tutorialsfdfsdfhttp://www.blogger.com/profile/08780252268386268059noreply@blogger.comBlogger67125tag:blogger.com,1999:blog-6427703763785525312.post-15179732890775136742014-04-07T22:46:00.003-07:002015-03-28T11:16:23.719-07:00<div dir="ltr" style="text-align: left;" trbidi="on">
<h1 style="text-align: center;">
<span style="color: orange;">TEXTBOX CONTROL</span></h1>
<br />
<div style="text-align: center;">
<script type="text/javascript">
( function() {
if (window.CHITIKA === undefined) { window.CHITIKA = { 'units' : [] }; };
var unit = {"calltype":"async[2]","publisher":"jayalaxmi0044","width":468,"height":180,"sid":"Chitika Default","color_button":"10404c","color_button_text":"ffffff"};
var placement_id = window.CHITIKA.units.length;
window.CHITIKA.units.push(unit);
document.write('<div id="chitikaAdBlock-' + placement_id + '"></div>');
}());
</script>
<script type="text/javascript" src="//cdn.chitika.net/getads.js" async></script>
</div>
<br />
Used to take any user input in the application. <input maxlength="120" name="Textbox" placeholder="TEXTBOX" size="21" type="text" /><br />
API: System.Windows.Forms.TextBox<br /><BR/>
<div class="divh1">Property of TextBox</div>
<div>
<!------------------------------------TABLE---------------------------->
<br />
<table border="1" bordercolor="#FFCC00" cellpadding="0" cellspacing="0" style="background-color: #ffffcc; width: auto;">
<tbody>
<tr>
<td align="center" style="height: auto; width: auto;"><b><span style="color: red;">Property</span></b></td>
<td align="center" style="height: auto; width: auto;"><b><span style="color: red;">Description</span></b></td>
</tr>
<tr>
<td class="tdtext">Name</td>
<td class="tdtext">Specifies the name of the control.</td>
</tr>
<tr>
<td class="tdtext">Text</td>
<td class="tdtext">Specifies the displayable text of the control.</td>
</tr>
<tr>
<td class="tdtext">BackColor</td>
<td class="tdtext">Specifies the background color of the control.</td>
</tr>
<tr>
<td class="tdtext">ForeColor</td>
<td class="tdtext">Specifies the foreground color of the control.</td>
</tr>
<tr>
<td class="tdtext">Font</td>
<td class="tdtext">Specifies the font style of the control‘s text.</td>
</tr>
<tr>
<td class="tdtext">Enabled</td>
<td class="tdtext">Enables / Disables the control.</td>
</tr>
<tr>
<td class="tdtext">Visible</td>
<td class="tdtext">Displays / Hides the control.</td>
</tr>
<tr>
<td class="tdtext">Cursor</td>
<td class="tdtext">Specifies the mouse pointer style, when it is over on the control.</td>
</tr>
<tr>
<td class="tdtext">Size</td>
<td class="tdtext">Specifies the Width and Height of the control.</td>
</tr>
<tr>
<td class="tdtext">Location</td>
<td class="tdtext">Specifies the X and Y co-ordinations of the control‘s position on the form.</td>
</tr>
<tr>
<td class="tdtext">TextAlign</td>
<td class="tdtext">Specifies the position of the text in the control (Left / Center / Right)</td>
</tr>
<tr>
<td class="tdtext">Image</td>
<td class="tdtext">Specifies the image that is to be displayed in the control along with the text.</td>
</tr>
<tr>
<td class="tdtext">ImageAlign</td>
<td class="tdtext">Specifies the position of the image in the control</td>
</tr>
<tr>
<td class="tdtext">TabIndex</td>
<td class="tdtext">Specifies the index of the control in the tab order.</td>
</tr>
<tr>
<td class="tdtext">ContextMenuStrip</td>
<td class="tdtext">Contains the reference of the respective context menu control.</td>
</tr>
<tr>
<td class="tdtext">ReadOnly</td>
<td class="tdtext">Enables / disables read-only nature of the textbox. In the read only textbox, the user can not enter any text.</td>
</tr>
<tr>
<td class="tdtext">MultiLine</td>
<td class="tdtext">Enables / disables multiple lines in the text box. By default, the text box will be single-line textbox.</td>
</tr>
<tr>
<td class="tdtext">WordWrap</td>
<td class="tdtext">This is used in multi line textboxes, which automatically moves the cursor to the next line, when the current line exceeds.</td>
</tr>
<tr>
<td class="tdtext">Scrollbars</td>
<td class="tdtext">Enables / disables scroll bars in the textbox.</td>
</tr>
<tr>
<td class="tdtext">PasswordChar</td>
<td class="tdtext">Used to specify the password display character. Ex: *</td>
</tr>
<tr>
<td class="tdtext">MaxLength</td>
<td class="tdtext">Specifies the maximum no. of characters that can be entered in the textbox.</td>
</tr>
</tbody></table>
</div><br/>
<div class="divh1">Property of Event of TextBox</div>
<div>
<!-----------------------------------TABLE------------------------------------------->
<br />
<table border="1" bordercolor="#FFCC00" cellpadding="0" cellspacing="0" style="background-color: #ffffcc; width: auto;">
<tbody>
<tr>
<td align="center" style="height: auto; width: auto;"><b><span style="color: red;">Event</span></b></td>
<td align="center" style="height: auto; width: auto;"><b><span style="color: red;">Description</span></b></td>
</tr>
<tr>
<td class="tdtext">TextChanged</td>
<td class="tdtext">Executes when any character is typed / removed in the textbox.</td>
</tr>
<tr>
<td class="tdtext">Click</td>
<td class="tdtext">Executes when the user clicks the control run time.</td>
</tr>
<tr>
<td class="tdtext">DoubleClick</td>
<td class="tdtext">Executes when the user double-clicks the control at run time.</td>
</tr>
<tr>
<td class="tdtext">MouseMove</td>
<td class="tdtext">Executes when the mouse pointer is moves across the control.</td>
</tr>
<tr>
<td class="tdtext">MouseEnter</td>
<td class="tdtext">Executes when the mouse pointer is focused on to the control.</td>
</tr>
<tr>
<td class="tdtext">MouseLeave</td>
<td class="tdtext">Executes when the mouse pointer is out of the button.</td>
</tr>
<tr>
<td class="tdtext">KeyPress</td>
<td class="tdtext">Executes when any key is pressed on the keyboard, while the focus is on the control.</td>
</tr>
<tr>
<td class="tdtext">Enter</td>
<td class="tdtext">Executes when the focus is entered into the control.</td>
</tr>
<tr>
<td class="tdtext">Leave</td>
<td class="tdtext">Executes when the focus is out of the control.</td>
</tr>
</tbody></table>
</div><br/>
<div class="divh1">Method of TextBox</div>
<div>
<!----------------------------------------TABLE------------------------------------------>
<br />
<table border="1" bordercolor="#FFCC00" cellpadding="0" cellspacing="0" style="background-color: #ffffcc; width: auto;">
<tbody>
<tr>
<td align="center" style="height: auto; width: 100px;"><b><span style="color: red;">Method</span></b></td>
<td align="center" style="height: auto; width: 500px;"><span style="color: red;"><b>Description</b></span></td>
</tr>
<tr>
<td style="height: auto; width: 100px;">Clear()</td>
<td style="height: auto; width: 500px;">Clears all the contents of the textbox and makes it empty</td>
</tr>
<tr>
<td style="height: auto; width: 100px;">Focus()</td>
<td style="height: auto; width: 500px;">Moves the focus to the control.</td>
</tr>
</tbody></table>
</div><br/>
<div class="divh1">Program for Demo Textbox</div>
<br/>
<pre class="brush:html">
<html>
<head>
<script type="text/javascript">
window.onload = functionundefined)
{
document.getElementByIdundefined'send').onclick = functionundefinede)
{
Name : alertundefineddocument.getElementByIdundefined"name").value);
return false;
}
}
</script>
</head>
<body>
<form method="post">
<div align="left">
<input id="name" name="name" type="text" />
<input id="send" name="send" type="submit" value="send" />
</div>
</form>
</body>
</html>
</pre>
<pre class="brush:csharp">
private void btnOK_Clickundefinedobject sender, EventArgs e)
{
string name = txtName.Text;
string message = name;
lblMessage.Text = message;
lblMessage.Visible = true;
}
</pre>
<div align="center">
<script type="text/javascript">
( function() {
if (window.CHITIKA === undefined) { window.CHITIKA = { 'units' : [] }; };
var unit = {"calltype":"async[2]","publisher":"jayalaxmi0044","width":550,"height":250,"sid":"Chitika Default","color_button":"10404c","color_button_text":"ffffff"};
var placement_id = window.CHITIKA.units.length;
window.CHITIKA.units.push(unit);
document.write('<div id="chitikaAdBlock-' + placement_id + '"></div>');
}());
</script>
<script type="text/javascript" src="//cdn.chitika.net/getads.js" async></script>
</div>
</div>fdfsdfhttp://www.blogger.com/profile/08780252268386268059noreply@blogger.com0tag:blogger.com,1999:blog-6427703763785525312.post-5494158654290220792014-04-07T22:39:00.002-07:002015-01-29T10:56:37.928-08:00<div dir="ltr" style="text-align: left;" trbidi="on">
<h2 style="text-align: center;">
<span style="color: orange; font-size: x-large;">Label Control</span></h2>
<br />
<div style="text-align: center;">
<script type="text/javascript">
( function() {
if (window.CHITIKA === undefined) { window.CHITIKA = { 'units' : [] }; };
var unit = {"calltype":"async[2]","publisher":"jayalaxmi0044","width":468,"height":180,"sid":"Chitika Default","color_button":"14404c","color_button_text":"ffffff"};
var placement_id = window.CHITIKA.units.length;
window.CHITIKA.units.push(unit);
document.write('<div id="chitikaAdBlock-' + placement_id + '"></div>');
}());
</script>
<script type="text/javascript" src="//cdn.chitika.net/getads.js" async></script>
</div>
<br/>
<div>
<div>
Mainly used for presentation purpose, to display a message or description to the user.</div>
<div>
<b>API:</b> System.Windows.Forms.Label</div>
</div>
<div>
<br /></div>
<div><br/>
<div class="divh1">Properties of Label</div>
<div>
<table border="1" bordercolor="#FFCC00" cellpadding="0" cellspacing="0" style="background-color: #ffffcc; width: auto;">
<tbody>
<tr>
<td align="center" style="height: auto; width: auto;"><b><span style="color: red;">Property</span></b></td>
<td align="center" style="height: auto; width: auto;"><b><span style="color: red;">Description</span></b></td>
</tr>
<tr>
<td class="tdtext"></td>
<td class="tdtext"></td>
</tr>
<tr>
<td class="tdtext">Text</td>
<td class="tdtext">Specifies the displayable text of the control.</td>
</tr>
<tr>
<td class="tdtext">BackColor</td>
<td class="tdtext">Specifies the background color of the control.</td>
</tr>
<tr>
<td class="tdtext">ForeColor</td>
<td class="tdtext">Specifies the foreground color of the control.</td>
</tr>
<tr>
<td class="tdtext">Font</td>
<td class="tdtext">Specifies the font style of the control‘s text.</td>
</tr>
<tr>
<td class="tdtext">Enabled</td>
<td class="tdtext">Enables / Disables the control.</td>
</tr>
<tr>
<td class="tdtext">Visible</td>
<td class="tdtext">Displays / Hides the control.</td>
</tr>
<tr>
<td class="tdtext">Cursor</td>
<td class="tdtext">Specifies the mouse pointer style, when it is over on the control.</td>
</tr>
<tr>
<td class="tdtext">Size</td>
<td class="tdtext">Specifies the Width and Height of the control.</td>
</tr>
<tr>
<td class="tdtext">Location</td>
<td class="tdtext">Specifies the X and Y co-ordinations of the control‘s position on the form.</td>
</tr>
<tr>
<td class="tdtext">TextAlign</td>
<td class="tdtext">Specifies the position of the text in the control (Left / Center / Right)</td>
</tr>
<tr>
<td class="tdtext">Image</td>
<td class="tdtext">Specifies the image that is to be displayed in the control along with the text.</td>
</tr>
<tr>
<td class="tdtext">ImageAlign</td>
<td class="tdtext">Specifies the position of the image in the control</td>
</tr>
<tr>
<td class="tdtext">TabIndex</td>
<td class="tdtext">Specifies the index of the control in the tab order.</td>
</tr>
<tr>
<td class="tdtext">ContextMenuStrip</td>
<td class="tdtext">Contains the reference of the respective context menu control.</td>
</tr>
<tr>
<td class="tdtext">AutoSize</td>
<td class="tdtext">Enables / disables automatic sizing of the control, based on the text.</td>
</tr>
<tr>
</tbody></table>
</div>
</div>
<div>
<br /></div>
<div>
<div class="divh1">Events of Label </div>
<div>
<table border="1" bordercolor="#FFCC00" cellpadding="0" cellspacing="0" style="background-color: #ffffcc; width: auto;">
<tbody>
<tr>
<td align="center" style="height: auto; width: auto;"><b><span style="color: red;">Event</span></b></td>
<td align="center" style="height: auto; width: auto;"><b><span style="color: red;">Description</span></b></td>
</tr>
<tr>
<td class="tdtext">Click</td>
<td class="tdtext">Executes when the user clicks the control run time.</td>
</tr>
<tr>
<td class="tdtext">DoubleClick</td>
<td class="tdtext">Executes when the user double-clicks the control at run time.</td>
</tr>
<tr>
<td class="tdtext">MouseMove</td>
<td class="tdtext">Executes when the mouse pointer is moves across the control.</td>
</tr>
<tr>
<td class="tdtext">MouseEnter</td>
<td class="tdtext">Executes when the mouse pointer is focused on to the control.</td>
</tr>
<tr>
<td class="tdtext">MouseLeave</td>
<td class="tdtext">Executes when the mouse pointer is out of the button.</td>
</tr>
<tr>
<td class="tdtext">KeyPress</td>
<td class="tdtext">Executes when any key is pressed on the keyboard, while the focus is on the control.</td>
</tr>
<tr>
<td class="tdtext">Enter</td>
<td class="tdtext">Executes when the focus is entered into the control.</td>
</tr>
<tr>
<td class="tdtext">Leave</td>
<td class="tdtext">Executes when the focus is out of the control.</td>
</tr>
</tbody></table>
</div>
</div>
<br/>
<div align="center">
<script type="text/javascript">
( function() {
if (window.CHITIKA === undefined) { window.CHITIKA = { 'units' : [] }; };
var unit = {"calltype":"async[2]","publisher":"jayalaxmi0044","width":550,"height":250,"sid":"Chitika Default","color_button":"10404c","color_button_text":"ffffff"};
var placement_id = window.CHITIKA.units.length;
window.CHITIKA.units.push(unit);
document.write('<div id="chitikaAdBlock-' + placement_id + '"></div>');
}());
</script>
<script type="text/javascript" src="//cdn.chitika.net/getads.js" async></script>
</div>
</div>fdfsdfhttp://www.blogger.com/profile/08780252268386268059noreply@blogger.com0tag:blogger.com,1999:blog-6427703763785525312.post-3471843640561685922014-04-07T22:27:00.000-07:002015-01-29T10:58:22.309-08:00<div dir="ltr" style="text-align: left;" trbidi="on">
<h1 style="text-align: center;">
<span style="color: orange; font-size: x-large;"><i>Button Control</i></span></h1>
<br />
<div style="text-align: center;">
<script type="text/javascript">
( function() {
if (window.CHITIKA === undefined) { window.CHITIKA = { 'units' : [] }; };
var unit = {"calltype":"async[2]","publisher":"jayalaxmi0044","width":468,"height":180,"sid":"Chitika Default","color_button":"14404c","color_button_text":"ffffff"};
var placement_id = window.CHITIKA.units.length;
window.CHITIKA.units.push(unit);
document.write('<div id="chitikaAdBlock-' + placement_id + '"></div>');
}());
</script>
<script type="text/javascript" src="//cdn.chitika.net/getads.js" async></script>
</div>
<br/>
<div>
It is known as action based control. Executes an operation, when it is clicked. <button type="button" onclick="alert('Welcome to Microsoft C#.NET Tutorials Learn C# by Your Self you need any help contact Microsoft C#.NET 4.0')">Button</button></div>
<div>
<b>API:</b> System.Windows.Forms.Button<br />
<br />
<div class="divh1">Properties of Button</div>
<br/>
<table border="1" bordercolor="#FFCC00" cellpadding="0" cellspacing="0" style="background-color: #ffffcc; width: auto;">
<tbody>
<tr>
<td align="center" style="height: auto; width: auto;"><b><span style="color: red;">Property</span></b></td>
<td align="center" style="height: auto; width: auto;"><b><span style="color: red;">Description</span></b></td>
</tr>
<tr>
<td class="tdtext">Name</td>
<td class="tdtext">Specifies the name of the control.</td>
</tr>
<tr>
<td class="tdtext">Text</td>
<td class="tdtext">Specifies the displayable text of the control.</td>
</tr>
<tr>
<td class="tdtext">BackColor</td>
<td class="tdtext">Specifies the background color of the control.</td>
</tr>
<tr>
<td class="tdtext">ForeColor</td>
<td class="tdtext">Specifies the foreground color of the control.</td>
</tr>
<tr>
<td class="tdtext">Font</td>
<td class="tdtext">Specifies the font style of the control‘s text.</td>
</tr>
<tr>
<td class="tdtext">Enabled</td>
<td class="tdtext">Enables / Disables the control.</td>
</tr>
<tr>
<td class="tdtext">Visible</td>
<td class="tdtext">Displays / Hides the control.</td>
</tr>
<tr>
<td class="tdtext">Cursor</td>
<td class="tdtext">Specifies the mouse pointer style, when it is over on the control.</td>
</tr>
<tr>
<td class="tdtext">Size</td>
<td class="tdtext">Specifies the Width and Height of the control.</td>
</tr>
<tr>
<td class="tdtext">Location</td>
<td class="tdtext">Specifies the X and Y co-ordinations of the control‘s position on the form.</td>
</tr>
<tr>
<td class="tdtext">TextAlign</td>
<td class="tdtext">Specifies the position of the text in the control (Left / Center / Right)</td>
</tr>
<tr>
<td class="tdtext">Image</td>
<td class="tdtext">Specifies the image that is to be displayed in the control along with the text.</td>
</tr>
<tr>
<td class="tdtext">ImageAlign</td>
<td class="tdtext">Specifies the position of the image in the control</td>
</tr>
<tr>
<td class="tdtext">TabIndex</td>
<td class="tdtext">Specifies the index of the control in the tab order.</td>
</tr>
<tr>
<td class="tdtext">ContextMenuStrip</td>
<td class="tdtext">Contains the reference of the respective context menu control.</td>
</tr>
<tr>
<td class="tdtext">FlatStyle </td>
<td class="tdtext">Specifies style of the button. (Flat / Popup / Standard / System).</td>
</tr>
</tbody></table>
<br />
<div class="divh1">Events of Button </div>
<br/>
<table border="1" bordercolor="#FFCC00" cellpadding="0" cellspacing="0" style="background-color: #ffffcc; width: auto;">
<tbody>
<tr>
<td align="center" style="height: auto; width: auto;"><b><span style="color: red;">Event</span></b></td>
<td align="center" style="height: auto; width: auto;"><b><span style="color: red;">Description</span></b></td>
</tr>
<tr>
<td class="tdtext">TextChanged</td>
<td class="tdtext">Executes when any character is typed / removed in the textbox.</td>
</tr>
<tr>
<td class="tdtext">Click</td>
<td class="tdtext">Executes when the user clicks the control run time.</td>
</tr>
<tr>
<td class="tdtext">DoubleClick</td>
<td class="tdtext">Executes when the user double-clicks the control at run time.</td>
</tr>
<tr>
<td class="tdtext">MouseMove</td>
<td class="tdtext">Executes when the mouse pointer is moves across the control.</td>
</tr>
<tr>
<td class="tdtext">MouseEnter</td>
<td class="tdtext">Executes when the mouse pointer is focused on to the control.</td>
</tr>
<tr>
<td class="tdtext">MouseLeave</td>
<td class="tdtext">Executes when the mouse pointer is out of the button.</td>
</tr>
<tr>
<td class="tdtext">KeyPress</td>
<td class="tdtext">Executes when any key is pressed on the keyboard, while the focus is on the control.</td>
</tr>
<tr>
<td class="tdtext">Enter</td>
<td class="tdtext">Executes when the focus is entered into the control.</td>
</tr>
<tr>
<td class="tdtext">Leave</td>
<td class="tdtext">Executes when the focus is out of the control.</td>
</tr>
</tbody></table>
<div>
</div>
<div style="text-align: center;">
<script type="text/javascript">
( function() {
if (window.CHITIKA === undefined) { window.CHITIKA = { 'units' : [] }; };
var unit = {"calltype":"async[2]","publisher":"jayalaxmi0044","width":550,"height":250,"sid":"Chitika Default","color_button":"10404c","color_button_text":"ffffff"};
var placement_id = window.CHITIKA.units.length;
window.CHITIKA.units.push(unit);
document.write('<div id="chitikaAdBlock-' + placement_id + '"></div>');
}());
</script>
<script type="text/javascript" src="//cdn.chitika.net/getads.js" async></script>
</div>
</div>
</div>fdfsdfhttp://www.blogger.com/profile/08780252268386268059noreply@blogger.com0tag:blogger.com,1999:blog-6427703763785525312.post-90422697591240024502014-04-07T11:12:00.001-07:002014-04-07T23:36:40.018-07:00C# Controls<div dir="ltr" style="text-align: left;" trbidi="on">
<h2 style="text-align: left;">
<i><span style="color: orange; font-size: large;"><span style="font-weight: normal;">List of Windows Form Controls </span>:</span></i></h2>
<h2 style="text-align: center;">
<ol>
<li><u style="color: blue; font-size: x-large; text-align: left;"><a href="http://microsoft-csharp-net.blogspot.com/2014/04/button.html">Button</a></u></li>
<li><u style="color: blue; font-size: x-large; text-align: left;"><a href="http://microsoft-csharp-net.blogspot.com/2014/04/label.html">Label</a></u></li>
<li><u style="color: blue; font-size: x-large; text-align: left;"><a href="http://microsoft-csharp-net.blogspot.in/2014/04/textbox.html">TextBox</a></u></li>
<li><span style="color: blue; font-size: large; text-align: left;"> </span><u style="color: blue; font-size: x-large; text-align: left;">CheckBox</u><span style="color: blue; font-size: large; text-align: left;">,</span></li>
<li><span style="color: blue; font-size: large; text-align: left;"> </span><u style="color: blue; font-size: x-large; text-align: left;">RadioButton,</u></li>
<li><u style="color: blue; font-size: x-large; text-align: left;">LinkLable,</u></li>
<li><u style="color: blue; font-size: x-large; text-align: left;">PictureBox</u><span style="color: blue; font-size: large; text-align: left;">,</span></li>
<li><u style="color: blue; font-size: x-large; text-align: left;">Panel</u><span style="color: blue; font-size: large; text-align: left;">,</span></li>
<li><u style="color: blue; font-size: x-large; text-align: left;">GroupBox</u><span style="color: blue; font-size: large; text-align: left;">,</span></li>
<li><u style="color: blue; font-size: x-large; text-align: left;">ListBox</u><span style="color: blue; font-size: large; text-align: left;">,</span></li>
<li><u style="color: blue; font-size: x-large; text-align: left;">ComboBox,</u></li>
<li><u style="color: blue; font-size: x-large; text-align: left;">NumericUpDown,</u></li>
<li><span style="color: blue; font-size: large; text-align: left;"> </span><u style="color: blue; font-size: x-large; text-align: left;">DomainUpDown</u><span style="color: blue; font-size: large; text-align: left;">,</span></li>
<li><u style="color: blue; font-size: x-large; text-align: left;">Date Time Picker</u><span style="color: blue; font-size: large; text-align: left;">,</span></li>
<li><u style="color: blue; font-size: x-large; text-align: left;">Month Calender</u><span style="color: blue; font-size: large; text-align: left;">,</span></li>
<li><u style="color: blue; font-size: x-large; text-align: left;">Track Bar</u><span style="color: blue; font-size: large; text-align: left;">,</span></li>
<li><u style="color: blue; font-size: x-large; text-align: left;">Timer</u><span style="color: blue; font-size: large; text-align: left;">,</span></li>
<li><u style="color: blue; font-size: x-large; text-align: left;">Progress Bar</u><span style="color: blue; font-size: large; text-align: left;">,</span></li>
<li><u style="color: blue; font-size: x-large; text-align: left;">Menu Strip</u><span style="color: blue; font-size: large; text-align: left;">,</span></li>
<li><u style="color: blue; font-size: x-large; text-align: left;">Context Menu Strip</u><span style="color: blue; font-size: large; text-align: left;">,</span></li>
<li><u style="color: blue; font-size: x-large; text-align: left;">Color Dialog</u><span style="color: blue; font-size: large; text-align: left;">,</span></li>
<li><u style="color: blue; font-size: x-large; text-align: left;">Font Dialog</u><span style="color: blue; font-size: large; text-align: left;">,</span></li>
<li><u style="color: blue; font-size: x-large; text-align: left;">FolderBrowserDialog</u><span style="color: blue; font-size: large; text-align: left;">,</span></li>
<li><u style="color: blue; font-size: x-large; text-align: left;">OpenFileDialog</u><span style="color: blue; font-size: large; text-align: left;">,</span></li>
<li><u style="color: blue; font-size: x-large; text-align: left;">SaveFileDialog</u><span style="color: blue; font-size: large; text-align: left;">,</span></li>
<li><u style="color: blue; font-size: x-large; text-align: left;">PrintDialog</u><span style="color: blue; font-size: large; text-align: left;">,</span></li>
<li><u style="color: blue; font-size: x-large; text-align: left;">RichTextBox</u><span style="color: blue; font-size: large; text-align: left;">,</span></li>
<li><u style="color: blue; font-size: x-large; text-align: left;">NotifyIcon</u><span style="color: blue; font-size: large; text-align: left;">,</span></li>
<li><u style="color: blue; font-size: x-large; text-align: left;">TabControl</u><span style="color: blue; font-size: large; text-align: left;">,</span></li>
<li><u style="color: blue; font-size: x-large; text-align: left;">TreeView</u><span style="color: blue; font-size: large; text-align: left;">,</span></li>
</ol>
</h2>
</div>
fdfsdfhttp://www.blogger.com/profile/08780252268386268059noreply@blogger.com0tag:blogger.com,1999:blog-6427703763785525312.post-19003774911001688772014-04-05T01:48:00.000-07:002015-03-28T11:31:07.018-07:00Working With Multi Form<div dir="ltr" style="text-align: left;" trbidi="on">
<div class="divh1">Working With Multi Form</div><br/>
<div style="text-align: center;">
<script type="text/javascript">
( function() {
if (window.CHITIKA === undefined) { window.CHITIKA = { 'units' : [] }; };
var unit = {"calltype":"async[2]","publisher":"jayalaxmi0044","width":468,"height":180,"sid":"Chitika Default","color_button":"10404c","color_button_text":"ffffff"};
var placement_id = window.CHITIKA.units.length;
window.CHITIKA.units.push(unit);
document.write('<div id="chitikaAdBlock-' + placement_id + '"></div>');
}());
</script>
<script type="text/javascript" src="//cdn.chitika.net/getads.js" async="async"></script>
</div>
<div>
<h2 style="text-align: left;">
<span style="color: blue;">Adding a new Form to the Project:</span></h2>
<div>
<ul style="text-align: left;">
<li>In the Solution Explorer, right click on the project and choose Add --> Windows Form.</li>
<li>In the dialog box, enter the name of the new form.</li>
<li>Then the new form will be created.</li>
</ul>
</div>
<h2 style="text-align: left;">
<span style="color: blue;">Deleting a Form from the Project:</span></h2>
<div>
<ul style="text-align: left;">
<li>In the Solution Explorer, right click on the required form, which you want to delete and click on Delete option.</li>
<li>Click on OK for confirmation.</li>
</ul>
</div>
<h2 style="text-align: left;">
<span style="color: blue;">Changing Startup Form:</span></h2>
<div>
<ul style="text-align: left;">
<li>Even, if you add multiple forms to the project, when the project is started, the Form1will be opened by default. This is called as Startup form.</li>
<li>To change the startup form, change the following statement with the required class name in the Program class‘s Main() method.</li>
</ul>
</div>
<div>
<b>Syn:</b> Application.Run(new <form name>());</div>
<div>
<b> Ex: </b>Application.Run(new Form2());</div>
<h2 style="text-align: left;">
<span style="color: blue;">Invoke Forms at Run Time (Programmatically):</span></h2>
<div>
<ul style="text-align: left;">
<li>To open any form at run time programmatically, you require to create an object for the form class.</li>
</ul>
</div>
<div>
FormName obj = new FormName();</div>
<div>
obj.Show()</div>
<div class="divh1">Program for Multi Form Handling </div>
<pre class="brush:csharp">/*Form1.cs
---------------------------------------*/
private void Form1_DoubleClick(object sender, EventArgs e)
{
Form2 f = new Form2();
f.Show();
}
</pre>
<div class="divh1">
System.Windows.Forms.Form Class</div><br/>
The <b>System.Windows.Forms.Form</b> offers few properties, methods and events for each user-defined form class.<br />
<table border="1" bordercolor="#FFCC00" cellpadding="0" cellspacing="0" style="background-color: #ffffcc; width: auto;">
<tbody>
<tr>
<td align="center" style="height: auto; width: 100px;"><b><span style="color: red;">Method</span></b></td>
<td align="center" style="height: auto; width: 500px;"><span style="color: red;"><b>Description</b></span></td>
</tr>
<tr>
<td style="height: auto; width: 100px;">Name</td>
<td style="height: auto; width: 500px;">Specifies the name of the form class.</td>
</tr>
<tr>
<td style="height: auto; width: 100px;">Text</td>
<td style="height: auto; width: 500px;">Specifies the title bar text of the form.</td>
</tr>
<tr>
<td style="height: auto; width: 100px;">ShowIcon</td>
<td style="height: auto; width: 500px;">Specifies whether the form icon is to be displayed or not.</td>
</tr>
<tr>
<td style="height: auto; width: 100px;">ShowInTaskBar</td>
<td style="height: auto; width: 500px;">Specifies whether the task bar icon is to be displayed or not.</td>
</tr>
<tr>
<td style="height: auto; width: 100px;">MinimizeBox</td>
<td style="height: auto; width: 500px;">Specifies whether the minimize button is to be displayed or not.</td>
</tr>
<tr>
<td style="height: auto; width: 100px;">MaximizeBox</td>
<td style="height: auto; width: 500px;">Specifies whether the maximize button is to be displayed or not.</td>
</tr>
<tr>
<td style="height: auto; width: 100px;">HelpButton</td>
<td style="height: auto; width: 500px;">Displays / hides the ? button in the form title bar.</td>
</tr>
<tr>
<td style="height: auto; width: 100px;">ControlBox</td>
<td style="height: auto; width: 500px;">Specifies whether the control box is to be displayed or not. Here
the control box means minimize, maximize and close buttons.</td>
</tr>
<tr>
<td style="height: auto; width: 100px;">Enabled</td>
<td style="height: auto; width: 500px;">Activates / Deactivates the functionality of the entire form.</td>
</tr>
<tr>
<td style="height: auto; width: 100px;">AutoScroll</td>
<td style="height: auto; width: 500px;">Enables / Disables automatic activation of scrollbars in the form.</td>
</tr>
<tr>
<td style="height: auto; width: 100px;">TopMost</td>
<td style="height: auto; width: 500px;">Enables / Disables automatic activation of scrollbars in the form.</td>
</tr>
<tr>
<td style="height: auto; width: 100px;">TopMost</td>
<td style="height: auto; width: 500px;">Activates / de-activates the nature of "Always on top"</td>
</tr>
<tr>
<td style="height: auto; width: 100px;">IsMDIContainer</td>
<td style="height: auto; width: 500px;">When it is true, the form acts as Parent form.</td>
</tr>
<tr>
<td style="height: auto; width: 100px;">BackColor</td>
<td style="height: auto; width: 500px;">Specifies the background color of the form.</td>
</tr>
<tr>
<td style="height: auto; width: 100px;">ForeColor</td>
<td style="height: auto; width: 500px;">Specifies default foreground color for all the controls of this form.</td>
</tr>
<tr>
<td style="height: auto; width: 100px;">Font</td>
<td style="height: auto; width: 500px;">Specifies default font for all the controls of this form.</td>
</tr>
<tr>
<td style="height: auto; width: 100px;">BackgroundImage</td>
<td style="height: auto; width: 500px;">Specifies the background image of the form. It requires an image file of any image format.</td>
</tr>
<tr>
<td style="height: auto; width: 100px;">BackgroundImageLayout</td>
<td style="height: auto; width: 500px;">Specifies mode of the background image. (None / Tile / Center /
Stretch / Zoom)</td>
</tr>
<tr>
<td style="height: auto; width: 100px;">Icon</td>
<td style="height: auto; width: 500px;">Specifies the icon of the form, displayed at left most side of the form title bar. It equires icon file with ".ico" file.</td>
</tr>
<tr>
<td style="height: auto; width: 100px;">WindowState</td>
<td style="height: auto; width: 500px;">Specifies the status of the form window. (Normal / Minimized / Maximized)</td>
</tr>
<tr>
<td style="height: auto; width: 100px;">Cursor</td>
<td style="height: auto; width: 500px;">Specifies the mouse cursor style. (Arrow, Hand etc.)</td>
</tr>
<tr>
<td style="height: auto; width: 100px;">FormBorderStyle</td>
<td style="height: auto; width: 500px;">None / FixedSingle / Fixed3D / FixedDialog / Sizable / FixedToolWindow / SizableToolWindow</td>
</tr>
<tr>
<td style="height: auto; width: 100px;">Size (Width and Heght)</td>
<td style="height: auto; width: 500px;">Specifies the size of the form (pixels format).</td>
</tr>
<tr>
<td style="height: auto; width: 100px;">Location (X and Y)</td>
<td style="height: auto; width: 500px;">Specifies the position of the form (pixels format).</td>
</tr>
<tr>
<td style="height: auto; width: 100px;">Opacity</td>
<td style="height: auto; width: 500px;">Specifies form graphics depth percentage. (1% to 100%)</td>
</tr>
</tbody></table>
<br/>
Syntax to access the Properties at run time: this.Property = value;<br/>
While you are changing the property values, you remember and follow the following syntaxes:<br/>
</div>
<div class="divh1">Assign Property value at runtime in Window Form Class</div>
<table border="1" bordercolor="#FFCC00" cellpadding="0" cellspacing="0" style="background-color: #ffffcc; width: auto;">
<tbody>
<tr>
<td align="center" style="height: auto; width: 100px;"><b><span style="color: red;">Property</span></b></td>
<td align="center" style="height: auto; width: 500px;"><span style="color: red;"><b>Statement to assign the value at run time</b></span></td>
</tr>
<tr>
<td style="height: auto; width: 100px;">Name</td>
<td style="height: auto; width: 500px;">Not possible to change at run time.</td>
</tr>
<tr>
<td style="height: auto; width: 100px;">Text</td>
<td style="height: auto; width: 500px;">this.Text = "xxxxxxxxxx";</td>
</tr>
<tr>
<td style="height: auto; width: 100px;">ShowIcon</td>
<td style="height: auto; width: 500px;">this.ShowIcon = true / false;</td>
</tr>
<tr>
<td style="height: auto; width: 100px;">ShowInTaskBar</td>
<td style="height: auto; width: 500px;">this.ShowInTaskbar = true / false;</td>
</tr>
<tr>
<td style="height: auto; width: 100px;">MinimizeBox</td>
<td style="height: auto; width: 500px;">this.MinimizeBox = true / false;</td>
</tr>
<tr>
<td style="height: auto; width: 100px;">MaximizeBox</td>
<td style="height: auto; width: 500px;">this.MaximizeBox = true / false;</td>
</tr>
<tr>
<td style="height: auto; width: 100px;">HelpButton</td>
<td style="height: auto; width: 500px;">this.HelpButton = true / false;</td>
</tr>
<tr>
<td style="height: auto; width: 100px;">ControlBox</td>
<td style="height: auto; width: 500px;">this.ControlBox = true / false;</td>
</tr>
<tr>
<td style="height: auto; width: 100px;">Enabled</td>
<td style="height: auto; width: 500px;">this.Enabled = true / false;</td>
</tr>
<tr>
<td style="height: auto; width: 100px;">AutoScroll</td>
<td style="height: auto; width: 500px;">this.AutoScroll = true / false;</td>
</tr>
<tr>
<td style="height: auto; width: 100px;">TopMost</td>
<td style="height: auto; width: 500px;">this.TopMost = true / false;</td>
</tr>
<tr>
<td style="height: auto; width: 100px;">IsMDIContainer</td>
<td style="height: auto; width: 500px;">this.IsMdiContainer = true / false;</td>
</tr>
<tr>
<td style="height: auto; width: 100px;">BackColor</td>
<td style="height: auto; width: 500px;">this.BackColor = System.Drawing.Color.xxxxxxx;</td>
</tr>
<tr>
<td style="height: auto; width: 100px;">ForeColor</td>
<td style="height: auto; width: 500px;">this.ForeColor = System.Drawing.Color.xxxxxxx;</td>
</tr>
<tr>
<td style="height: auto; width: 100px;">Font</td>
<td style="height: auto; width: 500px;">this.Font = new System.Drawing.Font("font name", size);</td>
</tr>
<tr>
<td style="height: auto; width: 100px;">BackgroundImage</td>
<td style="height: auto; width: 500px;">this.BackgroundImage = System.Drawing.Image.FromFile("image file
path");</td>
</tr>
<tr>
<td style="height: auto; width: 100px;">BackgroundImageLayout</td>
<td style="height: auto; width: 500px;">this.BackgroundImageLayout = System.Windows.Forms.ImageLayout.xxxxx</td>
</tr>
<tr>
<td style="height: auto; width: 100px;">Icon</td>
<td style="height: auto; width: 500px;">this.Icon = new System.Drawing.Icon("icon file path");</td>
</tr>
<tr>
<td style="height: auto; width: 100px;">WindowState</td>
<td style="height: auto; width: 500px;">this.WindowState = System.Windows.Forms.FormWindowState.Normal;
(or)
this.WindowState = System.Windows.Forms.FormWindowState.Minimized;
(or)
this.WindowState = System.Windows.Forms.FormWindowState.Maximized;</td>
</tr>
<tr>
<td style="height: auto; width: 100px;">Cursor</td>
<td style="height: auto; width: 500px;">this.Cursor = System.Windows.Forms.Cursors.xxxxx;</td>
</tr>
<tr>
<td style="height: auto; width: 100px;">FormBorderStyle</td>
<td style="height: auto; width: 500px;">this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.xxxxx;</td>
</tr>
<tr>
<td style="height: auto; width: 100px;">Size (Width and Heght)</td>
<td style="height: auto; width: 500px;">this.Size = new System.Drawing.Size(width, height);</td>
</tr>
<tr>
<td style="height: auto; width: 100px;">Location (X and Y)</td>
<td style="height: auto; width: 500px;">this.Location = new System.Drawing.Point(x, y);</td>
</tr>
<tr>
<td style="height: auto; width: 100px;">Opacity</td>
<td style="height: auto; width: 500px;">this.Opacity = n;</td>
</tr>
</tbody></table>
<br />
<div class="divh1">Methods of “System.Windows.Forms.Form” Class</div><br/>
<table border="1" bordercolor="#FFCC00" cellpadding="0" cellspacing="0" style="background-color: #ffffcc; width: auto;">
<tbody>
<tr>
<td align="center" style="height: auto; width: 100px;"><b><span style="color: red;">Property</span></b></td>
<td align="center" style="height: auto; width: 500px;"><span style="color: red;"><b>Description</b></span></td>
</tr>
<tr>
<td style="height: auto; width: 100px;">Hide()</td>
<td style="height: auto; width: 500px;">Makes the form invisible at run time.</td>
</tr>
<tr>
<td style="height: auto; width: 100px;">Show()</td>
<td style="height: auto; width: 500px;">Makes the form visible at run time.</td>
</tr>
<tr>
<td style="height: auto; width: 100px;">Close()</td>
<td style="height: auto; width: 500px;">Closes the form.</td>
</tr>
</tbody></table><br />
Syntax to access the Methods in the code: this.Method();<br />
<br />
<div class="divh1">Events of “System.Windows.Forms.Form” Class</div><br/>
<table border="1" bordercolor="#FFCC00" cellpadding="0" cellspacing="0" style="background-color: #ffffcc; width: auto;">
<tbody>
<tr>
<td align="center" style="height: auto; width: 100px;"><b><span style="color: red;">Method</span></b></td>
<td align="center" style="height: auto; width: 500px;"><span style="color: red;"><b>Description</b></span></td>
</tr>
<tr>
<td style="height: auto; width: 100px;">Load</td>
<td style="height: auto; width: 500px;">Executes whenever the form is loaded in the memory at run time, before the form is displayed on the screen.</td>
</tr>
<tr>
<td style="height: auto; width: 100px;">Shown</td>
<td style="height: auto; width: 500px;">Executes after the form is displayed on the screen.</td>
</tr>
<tr>
<td style="height: auto; width: 100px;">FormClosing</td>
<td style="height: auto; width: 500px;">Executes when the form is about to be closed.</td>
</tr>
<tr>
<td style="height: auto; width: 100px;">FormClosed</td>
<td style="height: auto; width: 500px;">Executes after the form is closed.</td>
</tr>
<tr>
<td style="height: auto; width: 100px;">Click</td>
<td style="height: auto; width: 500px;">Executes when the user clicks on the form at run time</td>
</tr>
<tr>
<td style="height: auto; width: 100px;">DoubleClick</td>
<td style="height: auto; width: 500px;">Executes when the user double-clicks on the form at run time.</td>
</tr>
<tr>
<td style="height: auto; width: 100px;">MouseMove</td>
<td style="height: auto; width: 500px;">Executes when the mouse pointer is moves across the form.</td>
</tr>
<tr>
<td style="height: auto; width: 100px;">MouseEnter</td>
<td style="height: auto; width: 500px;">Executes when the mouse pointer is focused on to the form.</td>
</tr>
<tr>
<td style="height: auto; width: 100px;">MouseLeave</td>
<td style="height: auto; width: 500px;">Executes when the mouse pointer is out of the form.</td>
</tr>
<tr>
<td style="height: auto; width: 100px;">Move</td>
<td style="height: auto; width: 500px;">Executes when the form is moved at run time, using keyboard or mouse.</td>
</tr>
<tr>
<td style="height: auto; width: 100px;">Resize</td>
<td style="height: auto; width: 500px;">Executes when the form is resized at run time.</td>
</tr>
<tr>
<td style="height: auto; width: 100px;">KeyPress</td>
<td style="height: auto; width: 500px;">Executes when any key is pressed on the keyboard, while running on the form.</td>
</tr>
<tr>
<td style="height: auto; width: 100px;">Enter</td>
<td style="height: auto; width: 500px;">Executes when the focus is got into the form.</td>
</tr>
<tr>
<td style="height: auto; width: 100px;">Leave</td>
<td style="height: auto; width: 500px;">Executes when the focus is out of the form.</td>
</tr>
</tbody></table>
<br />
<div class="divh1">Program for Windows Form Events</div>
<pre class="brush:csharp;">
private void Form1_Loadundefinedobject sender, EventArgs e)
{
this.Text = "This is load event.";
}
private void Form1_Moveundefinedobject sender, EventArgs e)
{
this.Text = "This is move event.";
}
private void Form1_Clickundefinedobject sender, EventArgs e)
{
this.Text = "This is click event.";
}
private void Form1_DoubleClickundefinedobject sender, EventArgs e)
{
this.Text = "This is double click event.";
}
private void Form1_FormClosedundefinedobject sender, FormClosedEventArgs e)
{
MessageBox.Showundefined"Bye. Thank you.");
}
private void Form1_Resizeundefinedobject sender, EventArgs e)
{
this.Text = "This is resize event.";
}
private void Form1_KeyPressundefinedobject sender, KeyPressEventArgs e)
{
this.Text = "This is key press event.";
}
</pre>
<div class="divh1">Program for Window Form Properties </div>
<pre class="brush:csharp;">
private void Form1_Clickundefinedobject sender, EventArgs e)
{
this.Text = "Thanks for clicking";
this.BackColor = Color.Green;
this.WindowState = FormWindowState.Maximized;
}
</pre>
<div class="divh1">Program Demo for Windows Form Properties </div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEigpRmWk-0ZGZfCagH5twLGN1nqeK1_wr9ysTCTcbeu1Lsn02jGWtKWk8V_s-J5PMmgstK_V7GidlLQ_67MUZIs-w14YQ2oY4eu4KD_RzGz7icE4uhiVIWVFy54TzxF8twjt9rpYMC_T7w/s1600/window+form+events.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEigpRmWk-0ZGZfCagH5twLGN1nqeK1_wr9ysTCTcbeu1Lsn02jGWtKWk8V_s-J5PMmgstK_V7GidlLQ_67MUZIs-w14YQ2oY4eu4KD_RzGz7icE4uhiVIWVFy54TzxF8twjt9rpYMC_T7w/s1600/window+form+events.jpg" height="158" width="200" /></a></div>
<pre class="brush:csharp;">
private void btnRed_Clickundefinedobject sender, EventArgs e)
{
this.BackColor = Color.Red;
}
private void btnGreen_Clickundefinedobject sender, EventArgs e)
{
this.BackColor = Color.Green;
}
private void btnBlue_Clickundefinedobject sender, EventArgs e)
{
this.BackColor = Color.Blue;
}
</pre>
<div class="divh1">Program Demo for Windows Form Properties </div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEibRkYcrYEdkBw02fpjcwavV_kpbS6xgbVUc86cZqvLe8rFJ9d9x_AiT7xXantpC2WpdY0GUig06A8D-k0u9K2-T5l10YC6vcVSg7vwtXiu9mnCkkFnZsYfszecyp60UlcG88WSIRSc8uk/s1600/window+form+event2.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEibRkYcrYEdkBw02fpjcwavV_kpbS6xgbVUc86cZqvLe8rFJ9d9x_AiT7xXantpC2WpdY0GUig06A8D-k0u9K2-T5l10YC6vcVSg7vwtXiu9mnCkkFnZsYfszecyp60UlcG88WSIRSc8uk/s1600/window+form+event2.jpg" height="170" width="200" /></a></div>
<pre class="brush:csharp;">
private void btnNormal_Clickundefinedobject sender, EventArgs e)
{
this.WindowState = FormWindowState.Normal;
}
private void btnMinimize_Clickundefinedobject sender, EventArgs e)
{
this.WindowState = FormWindowState.Minimized;
}
private void btnMaximize_Clickundefinedobject sender, EventArgs e)
{
this.WindowState = FormWindowState.Maximized;
}
private void btnExit_Clickundefinedobject sender, EventArgs e)
{
this.Closeundefined);
}
</pre>
<div class="divh1">Program Demo for Windows Form Properties </div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjbf601tS4JL2Kn2dat_V_kEQ0mcU7uQANyhMio65Hb_ZEq-41ckQNCqlCHQyG876jeiNzfNtG4qJGLUT2N9DZKS0UWVj02LsOwIFq5AOUspEIoyLq8mw9LzDbqOtpSXs7f1U_LwhbdXoE/s1600/window+form+event3.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjbf601tS4JL2Kn2dat_V_kEQ0mcU7uQANyhMio65Hb_ZEq-41ckQNCqlCHQyG876jeiNzfNtG4qJGLUT2N9DZKS0UWVj02LsOwIFq5AOUspEIoyLq8mw9LzDbqOtpSXs7f1U_LwhbdXoE/s1600/window+form+event3.jpg" height="170" width="200" /></a></div>
<pre class="brush:csharp;">
private void btnShowBackgroundImage_Clickundefinedobject sender, EventArgs e)
{
this.BackgroundImage = Image.FromFileundefined"c:\\globe.jpg");
this.BackgroundImageLayout = ImageLayout.Zoom;
}
private void btnClearBackgroundImage_Clickundefinedobject sender, EventArgs e)
{
this.BackgroundImage = null;
}
</pre>
<div align="center">
<script type="text/javascript">
( function() {
if (window.CHITIKA === undefined) { window.CHITIKA = { 'units' : [] }; };
var unit = {"calltype":"async[2]","publisher":"jayalaxmi0044","width":550,"height":250,"sid":"Chitika Default","color_button":"10404c","color_button_text":"ffffff"};
var placement_id = window.CHITIKA.units.length;
window.CHITIKA.units.push(unit);
document.write('<div id="chitikaAdBlock-' + placement_id + '"></div>');
}());
</script>
<script type="text/javascript" src="//cdn.chitika.net/getads.js" async></script>
</div>
</div>fdfsdfhttp://www.blogger.com/profile/08780252268386268059noreply@blogger.com0tag:blogger.com,1999:blog-6427703763785525312.post-47361191687424622332014-04-05T00:28:00.002-07:002015-03-28T11:31:55.291-07:00Event Handling<div dir="ltr" style="text-align: left;" trbidi="on">
<div class="divh1">Event Handling</div>
<div style="text-align: center;">
<script type="text/javascript">
( function() {
if (window.CHITIKA === undefined) { window.CHITIKA = { 'units' : [] }; };
var unit = {"calltype":"async[2]","publisher":"jayalaxmi0044","width":468,"height":180,"sid":"Chitika Default","color_button":"10404c","color_button_text":"ffffff"};
var placement_id = window.CHITIKA.units.length;
window.CHITIKA.units.push(unit);
document.write('<div id="chitikaAdBlock-' + placement_id + '"></div>');
}());
</script>
<script type="text/javascript" src="//cdn.chitika.net/getads.js" async></script>
</div>
<b>Def: </b> The event handling includes with executing some code, whenever the user performs an action.
<div>
The necessary code is to be written in a special method. That method is called as <b>Event Handler</b>.</div>
<h2 style="text-align: left;">
<span style="color: blue; font-size: small;">Event Handler:</span></h2>
<div>
<ul style="text-align: left;">
<li>An event handler is a method, which will be called automatically, whenever the user performs certain event at run time.</li>
<li>The event handler should be defined in the form class.</li>
</ul>
</div>
<div class="divh1"><b>Syntax:</b></div>
<pre class="brush:csharp">
private void controlname_eventname(object sender, EventArgs e)
{
//some code
}
</pre>
<div>
<div>
<ul style="text-align: left;">
<li>In the above syntax, there are two arguments:</li>
</ul>
</div>
<div>
<b><span style="color: red;">sender:</span></b> Represents the control, based on which the event is raised. For example, in the <b><span style="color: blue;">"button1_click"</span></b> event handler, the sender argument represents button1 control.</div>
<div>
<span style="color: red;"><b>e:</b></span> Contains some additional information about the event. For example, in the <b>MouseClick</b> event, the position of the mouse will be represented, where it is clicked.</div>
<div>
<ul style="text-align: left;">
<li>Event through you know the syntax of event handler properly, don‘t try to type it manually in the code. The event handler method should be generated through the proper way.</li>
<li>In the previous examples, you have generated the event handlers by double clicking on the controls.</li>
<li>But already you know that, for all the controls, there are multiple events. But when you double click the control, it will generate the event handler for only one event. That particular event can be called as Default event.</li>
<li>For example, the default event for the button is Click event.</li>
<li>If you want to implement the event handlers for other controls, you require to follow the steps given below.</li>
</ul>
</div>
<div class="divh1">Implementation of Event Handler: </div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiWX3xpl6glWs7NZ_XRNkvI7A9bTQYokmxujxXOg_pCRcnq9mapfjMZ7pxR-5cgzTKT-xxLp9drH1YJsRrMhUnBEXXB-8XAvQpi3-4CY7z8byGM2TW6jItMzdeQhDTPvLy1mWbsRfejf-o/s1600/implementation+of+event+handling.jpg" imageanchor="1" style="clear: right; float: right; margin-bottom: 1em; margin-left: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiWX3xpl6glWs7NZ_XRNkvI7A9bTQYokmxujxXOg_pCRcnq9mapfjMZ7pxR-5cgzTKT-xxLp9drH1YJsRrMhUnBEXXB-8XAvQpi3-4CY7z8byGM2TW6jItMzdeQhDTPvLy1mWbsRfejf-o/s1600/implementation+of+event+handling.jpg" height="200" width="82" /></a></div>
<div>
<ul style="text-align: left;">
<li>First, in the design window, select the form or control, for which you want to create the event handler.</li>
<li>Open Properties window, and click on Events option.</li>
<li>Select the required event, for which you want to create the event handler.</li>
<li>Press Enter.</li>
<li>Then the event handler will be created in the code window.</li>
</ul>
<br/>
</div>
<br/>
<div class="divh1">Demo on Event Handling </div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhr640DyllI-bLvNSW_02l8dMIv_-HVUHl_PJb8v-USJ3CqIPdiKLp7bfueGxQCcjXAyIF2GKdLzscZwlWXvxJfQRDDPlPniw8YsbcxsIWRDykkD7xH1ot-Fe6yUkd9h2mKEJ5jq1vYAUY/s1600/Click+Me.jpg" imageanchor="1"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhr640DyllI-bLvNSW_02l8dMIv_-HVUHl_PJb8v-USJ3CqIPdiKLp7bfueGxQCcjXAyIF2GKdLzscZwlWXvxJfQRDDPlPniw8YsbcxsIWRDykkD7xH1ot-Fe6yUkd9h2mKEJ5jq1vYAUY/s1600/Click+Me.jpg" /></a></div>
<pre class="brush:csharp;">
private void button1_Clickundefinedobject sender, EventArgs e)
{
MessageBox.Showundefined"You have clicked the button");
}
private void button1_MouseEnterundefinedobject sender, EventArgs e)
{
button1.BackColor = Color.Yellow;
button1.ForeColor = Color.DarkRed;
}
private void button1_MouseLeaveundefinedobject sender, EventArgs e)
{
button1.BackColor = Color.DarkRed;
button1.ForeColor = Color.Yellow;
}
</pre>
</div>
<div align="center">
<script type="text/javascript">
( function() {
if (window.CHITIKA === undefined) { window.CHITIKA = { 'units' : [] }; };
var unit = {"calltype":"async[2]","publisher":"jayalaxmi0044","width":550,"height":250,"sid":"Chitika Default","color_button":"10404c","color_button_text":"ffffff"};
var placement_id = window.CHITIKA.units.length;
window.CHITIKA.units.push(unit);
document.write('<div id="chitikaAdBlock-' + placement_id + '"></div>');
}());
</script>
<script type="text/javascript" src="//cdn.chitika.net/getads.js" async></script>
</div>
</div>fdfsdfhttp://www.blogger.com/profile/08780252268386268059noreply@blogger.com0tag:blogger.com,1999:blog-6427703763785525312.post-64065215879334620132014-04-05T00:11:00.000-07:002015-03-15T12:12:36.618-07:00Change Property Value at Run Tiime<div dir="ltr" style="text-align: left;" trbidi="on">
<div class="divh1">Change Property Value at Run Time</div>
<div style="text-align: center;">
<script type="text/javascript">
( function() {
if (window.CHITIKA === undefined) { window.CHITIKA = { 'units' : [] }; };
var unit = {"calltype":"async[2]","publisher":"jayalaxmi0044","width":468,"height":180,"sid":"Chitika Default","color_button":"10404c","color_button_text":"ffffff"};
var placement_id = window.CHITIKA.units.length;
window.CHITIKA.units.push(unit);
document.write('<div id="chitikaAdBlock-' + placement_id + '"></div>');
}());
</script>
<script type="text/javascript" src="//cdn.chitika.net/getads.js" async></script>
</div>
<ul style="text-align: left;">
<li>You can change the property values at run time (programmatically).</li>
<li>For example, you have designed a button with blue background. Later, after the user clicks it, you want to display that button with green background.</li>
<li>Then you require to change the <b>BackColor</b> property value at run time.</li>
<li>Syntax:</li>
<li><span style="color: red;">controlname.property = value;</span></li>
<li>Ex:</li>
<li><span style="color: red;">button1.Text = <b>Button is clicked</b></span></li>
<li>But sometimes, when you are trying to change some property values, you may face some problems.</li>
<li>For example, the following statements are not valid statements:</li>
</ul>
<div>
<span style="color: red;"> button1.BackColor = green;</span></div>
<div>
<span style="color: red;"> button1.Cursor = hand;</span></div>
<div>
<span style="color: red;"> button1.TextAlign = TopLeft;</span></div>
<div>
<ul style="text-align: left;">
<li>So, while you are changing the property values, you remember and follow the following syntaxes:</li>
</ul>
</div><br/>
<div class="divh1">Assign Property Values at Run Time</div>
<table border="1" bordercolor="#FFCC00" cellpadding="0" cellspacing="0" style="background-color: #ffffcc; width: auto;">
<tbody>
<tr>
<td align="center" style="height: auto; width: auto;"><b><span style="color: red;">Property</span></b></td>
<td align="center" style="height: auto; width: auto;"><b><span style="color: red;"> STATEMENT TO ASSIGN THE VALUE AT RUN TIME</span></b></td>
</tr>
<tr>
<td class="tdtext">Name</td>
<td class="tdtext">Not possible to change at run time</td>
</tr>
<tr>
<td class="tdtext">Text</td>
<td class="tdtext">controlname.Text = "xxxxx";</td>
</tr>
<tr>
<td class="tdtext">Enabled</td>
<td class="tdtext">controlname.Enabled = true / false;</td>
</tr>
<tr>
<td class="tdtext">Visible</td>
<td class="tdtext">controlname.Visible = true / false;</td>
</tr>
<tr>
<td class="tdtext">Location</td>
<td class="tdtext">controlname.Location = new System.Drawing.Point(x, y);</td>
</tr>
<tr>
<td class="tdtext">Size</td>
<td class="tdtext">controlname.Size = new System.Drawing.Size(width, height);</td>
</tr>
<tr>
<td class="tdtext">Font</td>
<td class="tdtext">controlname.Font = new System.Drawing.Font("font name", fontsize);</td>
</tr>
<tr>
<td class="tdtext">BackColor</td>
<td class="tdtext"> controlname.BackColor = System.Drawing.Color.xxxxx;</td>
</tr>
<tr>
<td class="tdtext">ForeColor</td>
<td class="tdtext">controlname.ForeColor = System.Drawing.Color.xxxxx;</td>
</tr>
<tr>
<td class="tdtext">Cursor</td>
<td class="tdtext">controlname.Cursor = System.Windows.Forms.Cursors.xxxxx;</td>
</tr>
<tr>
<td class="tdtext">Image</td>
<td class="tdtext">controlname.Image = System.Drawing.Image.FromFile("image file path");</td>
</tr>
<tr>
<td class="tdtext">TextAlign</td>
<td class="tdtext">controlname.TextAlign = System.Drawing.ContentAlignment.MiddleRight;</td>
</tr>
<tr>
<td class="tdtext">ImageAlign</td>
<td class="tdtext">controlname.TextAlign = System.Drawing.ContentAlignment.MiddleRight;</td>
</tr>
<tr>
<td class="tdtext">TabIndex</td>
<td class="tdtext">controlname.TabIndex = n;</td>
</tr>
<tr>
<td class="tdtext">ContextMenuStrip</td>
<td class="tdtext"> controlname.ContextMenuStrip = xxxxx;</td>
</tr>
</tbody>
</table>
<div class="divh1">Demo on Changing Property Values at Run Time</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhUuAUhr2ZLH19nurX2nRXzmnw93H5eWxkiszoA_pDlWWQHxnis_kor8w0cpQ8wFS_UGpBEJzgscq75h_H6dqSZ3JZH3t9mmT_INXkL90lcdilCqY5c8AnhN9JQ6TXOK1UpWeWXrgqbr2U/s1600/Change+Property+value+at+run+time.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhUuAUhr2ZLH19nurX2nRXzmnw93H5eWxkiszoA_pDlWWQHxnis_kor8w0cpQ8wFS_UGpBEJzgscq75h_H6dqSZ3JZH3t9mmT_INXkL90lcdilCqY5c8AnhN9JQ6TXOK1UpWeWXrgqbr2U/s1600/Change+Property+value+at+run+time.jpg" height="188" width="200" /></a></div>
<pre class="brush:csharp">
private void button2_Click(object sender, EventArgs e)
{
button1.Text = "My Test Button";
}
private void button3_Click(object sender, EventArgs e)
{
button1.Enabled = false;
}
private void button4_Click(object sender, EventArgs e)
{
button1.Enabled = true;
}
private void button5_Click(object sender, EventArgs e)
{
button1.Visible = false;
}
private void button6_Click(object sender, EventArgs e)
{
button1.Visible = true;
}
private void button7_Click(object sender, EventArgs e)
{
button1.Location = new Point(150, 400);
}
private void button8_Click(object sender, EventArgs e)
{
button1.Size = new Size(250, 100);
}
private void button9_Click(object sender, EventArgs e)
{
button1.Font = new Font("Showcard Gothic", 17);
}
private void button10_Click(object sender, EventArgs e)
{
button1.BackColor = Color.LightCoral;
}
private void button11_Click(object sender, EventArgs e)
{
button1.ForeColor = Color.Green;
}
private void button12_Click(object sender, EventArgs e)
{
button1.Image = Image.FromFile("c:\\flagindia.gif");
button1.ImageAlign = ContentAlignment.MiddleLeft;
button1.TextAlign = ContentAlignment.MiddleRight;
button1.Size = new Size(200, 60);
}
</pre>
<div align="center">
<script type="text/javascript">
( function() {
if (window.CHITIKA === undefined) { window.CHITIKA = { 'units' : [] }; };
var unit = {"calltype":"async[2]","publisher":"jayalaxmi0044","width":550,"height":250,"sid":"Chitika Default","color_button":"10404c","color_button_text":"ffffff"};
var placement_id = window.CHITIKA.units.length;
window.CHITIKA.units.push(unit);
document.write('<div id="chitikaAdBlock-' + placement_id + '"></div>');
}());
</script>
<script type="text/javascript" src="//cdn.chitika.net/getads.js" async></script>
</div>
</div>fdfsdfhttp://www.blogger.com/profile/08780252268386268059noreply@blogger.com0tag:blogger.com,1999:blog-6427703763785525312.post-19154994568793985842014-04-04T23:59:00.000-07:002015-03-15T12:36:23.571-07:00Control Handling Windows Form<div dir="ltr" style="text-align: left;" trbidi="on">
<div style="float:right;">
<b>Next :</b> <a href="http://microsoft-csharp-net.blogspot.com/2014/04/change-property-value-at-run-tiime.html">Change Property value at Run Time</a>
</div><br/>
<div class="divh1">Control Handling Windows Form</div><br/>
<div style="text-align: center;">
<script type="text/javascript">
( function() {
if (window.CHITIKA === undefined) { window.CHITIKA = { 'units' : [] }; };
var unit = {"calltype":"async[2]","publisher":"jayalaxmi0044","width":468,"height":180,"sid":"Chitika Default","color_button":"10404c","color_button_text":"ffffff"};
var placement_id = window.CHITIKA.units.length;
window.CHITIKA.units.push(unit);
document.write('<div id="chitikaAdBlock-' + placement_id + '"></div>');
}());
</script>
<script type="text/javascript" src="//cdn.chitika.net/getads.js" async></script>
</div>
<div class="divh1">Common Properties for all the controls:</div>
<b>The following properties commonly available for all the controls:</b><br/>
<div class="divh1">Common Properties</div>
<table border="1" bordercolor="#FFCC00" cellpadding="0" cellspacing="0" style="background-color: #ffffcc; width: auto;">
<tbody>
<tr>
<td align="center" style="height: auto; width: auto;"><b><span style="color: red;">Property</span></b></td>
<td align="center" style="height: auto; width: auto;"><b><span style="color: red;">Description</span></b></td>
</tr>
<tr>
<td class="tdtext">Name</td>
<td class="tdtext"> Specifies the name of the control.</td>
</tr>
<tr>
<td class="tdtext">Text</td>
<td class="tdtext"> Specifies the displayable text of the control.</td>
</tr>
<tr>
<td class="tdtext">BackColor</td>
<td class="tdtext"> Specifies the background color of the control.</td>
</tr>
<tr>
<td class="tdtext">ForeColor</td>
<td class="tdtext">Specifies the foreground color of the control.</td>
</tr>
<tr>
<td class="tdtext">Font</td>
<td class="tdtext">Specifies the font style of the control‘s text.</td>
</tr>
<tr>
<td class="tdtext">Enabled</td>
<td class="tdtext">Enables / Disables the control.</td>
</tr>
<tr>
<td class="tdtext">Visible</td>
<td class="tdtext"> Displays / Hides the control.</td>
</tr>
<tr>
<td class="tdtext">Cursor</td>
<td class="tdtext">Specifies the mouse pointer style, when the mouse is over on the control at run time.</td>
</tr>
<tr>
<td class="tdtext">Runtime</td>
<td class="tdtext"></td>
</tr>
<tr>
<td class="tdtext">Size</td>
<td class="tdtext">Specifies the Width and Height of the control.</td>
</tr>
<tr>
<td class="tdtext">Location</td>
<td class="tdtext">Specifies the X and Y co-ordinations of the control‘s position on the form.</td>
</tr>
<tr>
<td class="tdtext">TextAlign</td>
<td class="tdtext"> Specifies the position of the text in the control.</td>
</tr>
<tr>
<td class="tdtext">Image</td>
<td class="tdtext">Specifies the image that is to be displayed in the control along with the text.</td>
</tr>
<tr>
<td class="tdtext">ImageAlign</td>
<td class="tdtext">Specifies the position of the image in the control</td>
</tr>
<tr>
<td class="tdtext">TabIndex</td>
<td class="tdtext">Specifies the index of the control in the tab order.</td>
</tr>
<tr>
<td class="tdtext">ContentMenuStrip</td>
<td class="tdtext">Contains the reference of the respective context menu control.</td>
</tr>
</tbody>
</table><br/>
<div class="divh1">COMMON EVENTS FOR ALL THE CONTROLS:</div>
<p>The following events commonly available for all the controls:</p>
<div class="divh1">COMMON EVENTS</div><br/>
<table border="1" bordercolor="#FFCC00" cellpadding="0" cellspacing="0" style="background-color: #ffffcc; width: auto;">
<tbody>
<tr>
<td align="center" style="height: auto; width: auto;"><b><span style="color: red;">Event</span></b></td>
<td align="center" style="height: auto; width: auto;"><b><span style="color: red;">Description</span></b></td>
</tr>
<tr>
<td class="tdtext">Click</td>
<td class="tdtext">Executes when the user clicks the control run time.</td>
</tr>
<tr>
<td class="tdtext">DoubleClick</td>
<td class="tdtext">Executes when the user double-clicks the control at run time.</td>
</tr>
<tr>
<td class="tdtext">MouseMove</td>
<td class="tdtext">Executes when the mouse pointer is moves across the control.</td>
</tr>
<tr>
<td class="tdtext">MouseEnter</td>
<td class="tdtext">Executes when the mouse pointer is focused on to the control.</td>
</tr>
<tr>
<td class="tdtext">MouseLeave</td>
<td class="tdtext">Executes when the mouse pointer is out of the control.</td>
</tr>
<tr>
<td class="tdtext">KeyPress</td>
<td class="tdtext">Executes when any key is pressed on the keyboard, while the focus is on the control.</td>
</tr>
<tr>
<td class="tdtext">Enter</td>
<td class="tdtext">Executes when the focus is entered into the control.</td>
</tr>
<tr>
<td class="tdtext">Leave</td>
<td class="tdtext">Executes when the focus got out of the control.</td>
</tr>
</tbody>
</table>
<p><b>Event:</b> An event is a run time action that can be performed by the user.<br/>
Let us practice the above properties and events on the button control.</p>
<div class="divh1">Demo on Buttons </div>
<ul>
<li>Take a new Windows Forms Application project.</li>
<li>Design the form as follows:</li>
<li>To design the form as above set the following properties</li>
</ul>
<table>
<tr>
<td>
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjbyqJaK-NUEKr6Zft_1U1sDdh1sYNJVJWVqut-bUHw-VCFXuX5VJBiMTzzRhxIt72rH2dY7RZOL0I2i63I6cjl37uA_kRcg4TrLj4UP5gwvq_lPbil0RTbQ21tphqygCjAM3HpNscQ5eo/s1600/demo+on+buttons.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img alt="Windows Form Controls" border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjbyqJaK-NUEKr6Zft_1U1sDdh1sYNJVJWVqut-bUHw-VCFXuX5VJBiMTzzRhxIt72rH2dY7RZOL0I2i63I6cjl37uA_kRcg4TrLj4UP5gwvq_lPbil0RTbQ21tphqygCjAM3HpNscQ5eo/s1600/demo+on+buttons.jpg" height="155" width="200" /></a></td>
<td>
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg4SPDyNTukDRFFBUv4Q6PDX4gu6ff1aEG_oX4imlgPFx84hVk-zsUVGt8N98CCOAftjvSoqagI4SpND8ltd380z8KUV93FapaQgYP7Puk08M_48N3L6A_8avb0B-DIzlJ72CCmwppYddQ/s1600/property+of+button.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img alt="Properties of Controls" border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg4SPDyNTukDRFFBUv4Q6PDX4gu6ff1aEG_oX4imlgPFx84hVk-zsUVGt8N98CCOAftjvSoqagI4SpND8ltd380z8KUV93FapaQgYP7Puk08M_48N3L6A_8avb0B-DIzlJ72CCmwppYddQ/s1600/property+of+button.jpg" height="200" width="194" /></a>
</td>
</tr>
</table>
<ul>
<li>Double click on Button1 and Write the following code:</li>
</ul>
<pre class="brush:csharp;">
private void button1_Click(object sender, EventArgs e)
{
DateTime dt = DateTime.Now;
MessageBox.Show(dt.ToString());
}
</pre>
<ul>
<li>Double click on Button2 and Write the following code:</li>
</ul>
<pre class="brush:csharp;">
private void button2_Click(object sender, EventArgs e)
{
Random r = new Random();
int n = r.Next(1, 500);
MessageBox.Show(n.ToString());
}
</pre>
<ul>
<li>Double click on Button3 and Write the following code:</li>
</ul>
<pre class="brush:csharp;">
private void button3_Click(object sender, EventArgs e)
{
MessageBox.Show("Bye....");
Application.Exit();
}
</pre>
<div style="float:right;">
<b>Next :</b> <a href="http://microsoft-csharp-net.blogspot.com/2014/04/change-property-value-at-run-tiime.html">Change Property value at Run Time</a>
</div>
<div align="center">
<script type="text/javascript">
( function() {
if (window.CHITIKA === undefined) { window.CHITIKA = { 'units' : [] }; };
var unit = {"calltype":"async[2]","publisher":"jayalaxmi0044","width":550,"height":250,"sid":"Chitika Default","color_button":"10404c","color_button_text":"ffffff"};
var placement_id = window.CHITIKA.units.length;
window.CHITIKA.units.push(unit);
document.write('<div id="chitikaAdBlock-' + placement_id + '"></div>');
}());
</script>
<script type="text/javascript" src="//cdn.chitika.net/getads.js" async></script>
</div>
</div>fdfsdfhttp://www.blogger.com/profile/08780252268386268059noreply@blogger.com0tag:blogger.com,1999:blog-6427703763785525312.post-53043396348065888272014-04-02T08:20:00.000-07:002015-06-24T02:01:13.649-07:00LINQ With Lambda Expressions<div dir="ltr" style="text-align: left;" trbidi="on">
<div class="divh1">LINQ With Lambda Expressions</div><br/>
<ul>
<li>LINQ queries can be written in two syntaxes:
<ol>
<li> General Query Syntax</li>
<li> Lambda Expression Syntax</li>
</ol></li>
<li>The previously written applications are written with General Query Syntax.</li>
<li>Syntax for Lambda Expression:</li>
</ul>
<span style="color: red;">DataSource.Clause(DataAliasName => Expression)</span>
<div>
<ul style="text-align: left;">
<li>Ex: <span style="color: red;">stu.Where(s => s.Marks < 300)</span></li>
</ul>
</div>
<div class="divh1">Program with LINQ to LAMBDA EXPRESSIONS</div>
<pre class="brush:csharp">
Student.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace LINQtoObjectsDemo
{
class Student
{
//fields
public int StudentID;
public string Name;
public string Course;
public int Marks;
//constructor
public Student(int StudentID, string Name, string Course, int Marks)
{
this.StudentID = StudentID;
this.Name = Name;
this.Course = Course;
this.Marks = Marks;
}
}
}
Program.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace LINQwithLambaExpressions
{
class Program
{
static void Main(string[] args)
{
//data source
Student[] stu = { new Student(101, "Prakash", "MBA", 765),
new Student(102, "Pradeep", "MBA", 471),
new Student(103, "Pushpa", "Msc", 590),
new Student(104, "Purna", "MCA", 223),
new Student(105, "Purnima", "MCA", 450)};
//linq query with where clause
IEnumerable<Student> result1 = stu.Where(s => s.Course == "MCA");
Console.WriteLine("MCA Students:");
foreach (Student r in result1)
Console.WriteLine(r.StudentID + ", " + r.Name + ", " + r.Course + ", " + r.Marks);
//linq query with compound where clause
IEnumerable<Student> result2 = stu.Where(s => s.Name.EndsWith("a") && s.Marks >= 400 && s.Marks <= 600);
Console.WriteLine("\nStudents whose name ends with 'a', and marks is >=400 and <=600:");
foreach (Student r in result2)
Console.WriteLine(r.StudentID + ", " + r.Name + ", " + r.Course + ", " + r.Marks);
//linq query with orderby clause
IEnumerable<Student> result4 = stu.OrderBy(s => s.Marks);
Console.WriteLine("\nStudents (sort on marks):");
foreach (Student r in result4)
Console.WriteLine(r.StudentID + ", " + r.Name + ", " + r.Course + ", " + r.Marks);
//linq query with orderby clause (descending)
IEnumerable<Student> result5 = stu.OrderByDescending(s => s.Marks);
Console.WriteLine("\nStudents (sort on marks - descending):");
foreach (Student r in result5)
Console.WriteLine(r.StudentID + ", " + r.Name + ", " + r.Course + ", " + r.Marks);
//linq query with group clause
IEnumerable<IGrouping<string, Student>> result6 = stu.GroupBy(s => s.Course);
Console.WriteLine("\nStudents with grouping:");
foreach (IGrouping<string, Student>> StuGrp in result6)
{
Console.WriteLine(StuGrp.Key + ":");
foreach (Student r in StuGrp)
Console.WriteLine(" " + r.StudentID + ", " + r.Name + ", " + r.Course + ", " + r.Marks);
}
Console.Read();
}
}
}
</pre>
</div>
<div style="text-align: right;">
<b>Previous Page : <a href="http://microsoft-csharp-net.blogspot.com/2014/03/linq_24.html">LINQ</a></b></div>
</div>fdfsdfhttp://www.blogger.com/profile/08780252268386268059noreply@blogger.com0tag:blogger.com,1999:blog-6427703763785525312.post-38685658558381713442014-03-31T09:05:00.001-07:002015-03-15T13:11:02.215-07:00Development of Form<div dir="ltr" style="text-align: left;" trbidi="on">
<div class="divh1">Development of Form</i></span></div>
<br />
<div style="text-align: center;">
<script type="text/javascript">
( function() {
if (window.CHITIKA === undefined) { window.CHITIKA = { 'units' : [] }; };
var unit = {"calltype":"async[2]","publisher":"jayalaxmi0044","width":468,"height":180,"sid":"Chitika Default","color_button":"10404c","color_button_text":"ffffff"};
var placement_id = window.CHITIKA.units.length;
window.CHITIKA.units.push(unit);
document.write('<div id="chitikaAdBlock-' + placement_id + '"></div>');
}());
</script>
<script type="text/javascript" src="//cdn.chitika.net/getads.js" async></script>
</div>
<br/>
<b>It includes with two stages:</b>
<ol>
<li>Designing</li>
<li>Coding</li>
</ol>
<div class="divh1"> 1) Designing the Form:</span></div>
<ul>
<li>Drag and Drop the controls from the ToolBox.</li>
<li>A Sample Windows Application Project (with Login Form)</li>
</ul>
<table>
<tr>
<td>
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjA7gdB-KUVnlKY-7Oyj1U46mJJmGUyQKkhBLkr8rlzCtA2RiWXVuXprr8y8Jhf86-cKpy0bbTW5RXz34xdWLyXaXqy31OR_5XrXD404p2Yx4ulZAZaSKnRyyE4heVg4yGr_8RWlAlYHOc/s1600/Window+Login+Form.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img alt="Window Login Form" border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjA7gdB-KUVnlKY-7Oyj1U46mJJmGUyQKkhBLkr8rlzCtA2RiWXVuXprr8y8Jhf86-cKpy0bbTW5RXz34xdWLyXaXqy31OR_5XrXD404p2Yx4ulZAZaSKnRyyE4heVg4yGr_8RWlAlYHOc/s1600/Window+Login+Form.jpg" height="231" width="300" /></a></td>
<td>
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjmXBiGMrwUHzFL70UP5l0W7qJ0aQann1PLEsFT2ue1XcxfhSVWhgw-101IN_M26wWIvBuy9RKo-ea5TSQckyaL9LIhnERHF2M6YS3anynov5M_G1r4Efe_xkJPErF5O-nt5xzm4h-YD24/s1600/window+form+designing.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img alt="Window Form Designing" border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjmXBiGMrwUHzFL70UP5l0W7qJ0aQann1PLEsFT2ue1XcxfhSVWhgw-101IN_M26wWIvBuy9RKo-ea5TSQckyaL9LIhnERHF2M6YS3anynov5M_G1r4Efe_xkJPErF5O-nt5xzm4h-YD24/s1600/window+form+designing.jpg" height="231" width="300" /></a>
</td>
</tr>
</table>
<br />
<ul>
<li>Select the control and set the properties as your wish.</li>
<li>For example, set the following properties as per given below:</li>
<ol><li>Form1</li> <ul><li>Text: Login</li></ul>
<li>Label1</li><ul><li>Text: User Name</li></ul>
<li>Label2</li><ul><li>Text: Password</li></ul>
<li>TextBox1</li><ul><li>(No properties are required in this example)</li></ul>
<li>TextBox2</li><ul><li>PasswordChar: *</li></ul>
<li>Button1</li><ul><li>Text: OK</li></ul>
<li>Button2</li><ul><li>Text: Cancel</li></ul>
</ol>
</ul>
<div class="divh1"> 2) Coding the Form:</span></div>
<ol>
<li>Double click on the controls and write the code in the Code window.</li>
<li>For example, double click on OK button and write the following code:</li>
</ol>
<pre class="brush:csharp;">
private void button1_Click(object sender, EventArgs e)
{
if (textBox1.Text == "system" && textBox2.Text == "manager")
MessageBox.Show("Login is successful.");
else
MessageBox.Show("Invalid Login.");
}
</pre>
<ul>
<li>And then, double click on ―Cancel‖ button and write the following code:</li>
</ul>
<pre class="brush:csharp;">
private void button2_Click(object sender, EventArgs e)
{
Application.Exit();
}
</pre>
<ul>
<li>The above process is called as Form coding.</li>
</ul>
<div class="divh1">Every Form is a Class:</span></div>
<ol>
<li>C#.NET recognizes every form as a class.</li>
<li>In VB 6.0, every form is known as an object for the Form class. But in C#, every form is a class; so that at run time, you can create a ny no. of objects as your wish. For example, if you want to display Login form twice at run time, you can simply create two objects and can show it.</li>
</ol>
<div class="divh1">The Automatic Generated Code:</span></div>
<ol>
<li>While you design the controls, the Visual Studio generates some automatic code in the “Form1.Designer.cs” file.</li>
<li>To open this file, Open Solution Explorer, Expand Form1, then double click on Form1.Designer.cs.</li>
<li>For example, you can see the automatic generated code for the previous Login example</li>
</ol><br/>
<div class="divh1">Default.aspx.cs:</div>
<pre class="brush:csharp;">
namespace WindowsFormsApplication1
{
partial class Form1
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed;
otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.textBox1 = new System.Windows.Forms.TextBox();
this.textBox2 = new System.Windows.Forms.TextBox();
this.button1 = new System.Windows.Forms.Button();
this.button2 = new System.Windows.Forms.Button();
this.label1 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
this.SuspendLayout();
//
// textBox1
//
this.textBox1.Location = new System.Drawing.Point(186, 44);
this.textBox1.Margin = new System.Windows.Forms.Padding(5, 4, 5, 4);
this.textBox1.Name = "textBox1";
this.textBox1.Size = new System.Drawing.Size(232, 27);
this.textBox1.TabIndex = 0;
//
// textBox2
//
this.textBox2.Location = new System.Drawing.Point(186, 102);
this.textBox2.Margin = new System.Windows.Forms.Padding(5, 4, 5, 4);
this.textBox2.Name = "textBox2";
this.textBox2.PasswordChar = '*';
this.textBox2.Size = new System.Drawing.Size(232, 27);
this.textBox2.TabIndex = 1;
//
// button1
//
this.button1.Location = new System.Drawing.Point(186, 167);
this.button1.Margin = new System.Windows.Forms.Padding(5, 4, 5, 4);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(107, 37);
this.button1.TabIndex = 2;
this.button1.Text = "OK";
this.button1.UseVisualStyleBackColor = true;
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// button2
//
this.button2.Location = new System.Drawing.Point(314, 167);
this.button2.Margin = new System.Windows.Forms.Padding(5, 4, 5, 4);
this.button2.Name = "button2";
this.button2.Size = new System.Drawing.Size(107, 37);
this.button2.TabIndex = 3;
this.button2.Text = "Cancel";
this.button2.UseVisualStyleBackColor = true;
this.button2.Click += new System.EventHandler(this.button2_Click);
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(64, 48);
this.label1.Margin = new System.Windows.Forms.Padding(5, 0, 5, 0);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(104, 19);
this.label1.TabIndex = 4;
this.label1.Text = "User Name:";
//
// label2
//
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(64, 107);
this.label2.Margin = new System.Windows.Forms.Padding(5, 0, 5, 0);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(93, 19);
this.label2.TabIndex = 5;
this.label2.Text = "Password:";
//
// Form1
//
this.AutoScaleDimensions = new System.Drawing.SizeF(10F, 19F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(492, 244);
this.Controls.Add(this.label2);
this.Controls.Add(this.label1);
this.Controls.Add(this.button2);
this.Controls.Add(this.button1);
this.Controls.Add(this.textBox2);
this.Controls.Add(this.textBox1);
this.Font = new System.Drawing.Font("Tahoma", 12F,
System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.Margin = new System.Windows.Forms.Padding(5, 4, 5, 4);
this.Name = "Form1";
this.Text = "Login";
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.TextBox textBox1;
private System.Windows.Forms.TextBox textBox2;
private System.Windows.Forms.Button button1;
private System.Windows.Forms.Button button2;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Label label2;
}
}
</pre>
<ol>
<li>Don‘t worry about the above automatic generated code; it will be generated automatically, while you design the form in the Design window.</li>
<li>The entire code is generated in a method called InitializeComponent().</li>
<li>Finally, coming to a conclusion; every form contains two files:</li>
<li>Form1.Designer.cs</li>
<li>Contains the code for designing (Automatically generated code by Visual Studio).</li>
<li>Form1.cs</li>
<li>Contains the actual functionality code (Written by the Programmer).</li>
</ol>
<div class="divh1">Class Definition Syntax of a Windows Form</div>
<pre class="brush:csharp;">
//Form1.cs
importing section;
namespace ProjectName
{
public partial class FormName : Form
{
public FormName()
{
InitializeComponent();
}
}
}
</pre>
<div class="divh1">Rules for the Form class definition:</div>
<ol>
<li>In the importing section, you can import the necessary namespaces that you want.</li>
<li>The namespace name should be same as project name.</li>
<li>A user-defined class with the form name is to be defined.</li>
<li>It should be the sub class of "System.Windows.Forms.Form" class; as it offers some visual design, properties, methods and events for the user-defined form class.</li>
<li>It will be defined as a public class (this is optional). Whenever it is a public class, in future, it can be accessed from other projects also.
It should be defined as "partial" class, as its definition is written in the following two files.
--> Form1.cs
--> Form1.Designer.cs</li>
<li>It should contain a constructor, with a statement called InitializeComponent();, which calls the designer code that is generated in Form1.Designer.cs file.</li>
</ol>
<div class="divh1"> “Program.cs” file in Windows Forms Applications:</div>
<ol>
<div style="float:right;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjFRrgO5npODsraC6rVnJIHkAB_Ayrj5d4e_kf_xk0Bd-46t_F8GzNpYUmTlyfAvYn4Rq5W6BABDsIjh5Jtkka_Vc1evRX0zgNiZE-siHsc15dH9Vla_ygL_OlbZFX4QXvZHppmgA5KICc/s1600/Progress.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjFRrgO5npODsraC6rVnJIHkAB_Ayrj5d4e_kf_xk0Bd-46t_F8GzNpYUmTlyfAvYn4Rq5W6BABDsIjh5Jtkka_Vc1evRX0zgNiZE-siHsc15dH9Vla_ygL_OlbZFX4QXvZHppmgA5KICc/s1600/Progress.jpg" height="231" width="320" /></a></div>
<li>Generally, when you Start the windows application project, automatically the Form1 will be appeared on the screen.</li>
<li>Then don‘t think like directly Form1 will be opened.</li>
<li>In fact, when you click on Start option, the Main() method will be invoked first.</li>
<li>Like Console Applications, Main() method is located in Program.cs file</li>
<li>For reference you open Solution Explorer ―> Program.cs file.</li>
<li>In the Main() method, you can see two important statements.</li>
</ol>
<div class="divh1">Application.EnableVisualStyles();</div>
<p>
This statement enables the better styles (for sleek appearance) for the entire application, based on the current working theme offered by the O/S.
</p>
<div class="divh1">Application.Run(new Form1());</div>
<p>
This statement creates a new Form1 class object and that object will be shown on the screen.</p>
</div>
<div align="center">
<script type="text/javascript">
( function() {
if (window.CHITIKA === undefined) { window.CHITIKA = { 'units' : [] }; };
var unit = {"calltype":"async[2]","publisher":"jayalaxmi0044","width":550,"height":250,"sid":"Chitika Default","color_button":"10404c","color_button_text":"ffffff"};
var placement_id = window.CHITIKA.units.length;
window.CHITIKA.units.push(unit);
document.write('<div id="chitikaAdBlock-' + placement_id + '"></div>');
}());
</script>
<script type="text/javascript" src="//cdn.chitika.net/getads.js" async></script>
</div>fdfsdfhttp://www.blogger.com/profile/08780252268386268059noreply@blogger.com0tag:blogger.com,1999:blog-6427703763785525312.post-4424803956725119332014-03-31T08:59:00.003-07:002015-03-15T13:29:19.144-07:00Windows Forms Applications<div dir="ltr" style="text-align: left;" trbidi="on">
<div style="float:right;"><b>Next : </b><a href="http://microsoft-csharp-net.blogspot.com/2014/03/development-of-form.html">Development of Form</a></div><br/>
<div class="divh1">Windows Forms Applications</div><br/>
<div style="text-align: center;">
<script type="text/javascript">
( function() {
if (window.CHITIKA === undefined) { window.CHITIKA = { 'units' : [] }; };
var unit = {"calltype":"async[2]","publisher":"jayalaxmi0044","width":468,"height":180,"sid":"Chitika Default","color_button":"10404c","color_button_text":"ffffff"};
var placement_id = window.CHITIKA.units.length;
window.CHITIKA.units.push(unit);
document.write('<div id="chitikaAdBlock-' + placement_id + '"></div>');
}());
</script>
<script type="text/javascript" src="//cdn.chitika.net/getads.js" async></script>
</div>
<p>C# supports two kinds of User Interfaces.</p>
<div class="divh1"> C.U.I (Character User Interface)</div>
<div style="float:right;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg0SCY3lvFmM-8Rb5HuQ9z6sI1cgVQSHluLE2wAkO9-t7Zd_IsAcYwz7tvWlewtViXp6NBM_ayzYmTlyx1ycBDNI4eK3-hLkno6euJKuNvvDhfOzY3JHsYtu2ISTzBQxH8zXctnbWNU68Q/s1600/cui.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img alt="Character User Interface" border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg0SCY3lvFmM-8Rb5HuQ9z6sI1cgVQSHluLE2wAkO9-t7Zd_IsAcYwz7tvWlewtViXp6NBM_ayzYmTlyx1ycBDNI4eK3-hLkno6euJKuNvvDhfOzY3JHsYtu2ISTzBQxH8zXctnbWNU68Q/s1600/cui.jpg" height="120" width="200" /></a></div>
<ol>
<li>This user interface supports a blank screen, with some characters only.</li>
<li>It is not attractive for the user. That‘s why it is not suitable for the live projects.</li>
</ol>
<div class="divh1"> G.U.I (Graphical User Interface)</div>
<div style="float:right;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhQyYA2N8s2sGm4lSQkUQB8wPmpvlhbBsoOOD69Z9YJIulTCQL0ogf7su-ybmaoZghauiCi2zFsBbBCwcMxCNCHaWTDLG8RGwUyU0Sseqf8382HaQGoJsh-uLqFoN1yFXZkhg518-nqsyw/s1600/GUI.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img alt="Graphical User Interface" border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhQyYA2N8s2sGm4lSQkUQB8wPmpvlhbBsoOOD69Z9YJIulTCQL0ogf7su-ybmaoZghauiCi2zFsBbBCwcMxCNCHaWTDLG8RGwUyU0Sseqf8382HaQGoJsh-uLqFoN1yFXZkhg518-nqsyw/s1600/GUI.jpg" height="120" width="200" /></a></div>
<ol>
<li>It supports graphical components like windows, icons, mouse pointer, toolbars, status bars, buttons etc.</li>
<li>It is attractive for the user. That‘s why it is suitable for the live projects. </li>
<li>Almost all the software‘s you are using today like Notepad, WordPad, Paint, MS Word, My computer and My documents etc., are the GUI applications.</li>
</ol>
<div class="divh1">Windows Forms Application:</div>
<div style="float:right;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhAi7Uz-E0hohBsZkxdLRZLpv1kaVwiNP-Mu4SqTcoOY8GDbVF-V9HEyhUaY1dTKn4XGTd9GZ9Sna6lz3W-vqg0FWLntVmE_4XNbHw9y-924WTUHYzN7h6tLdTIKSNnPyeAZ38et-12yPU/s1600/wfa.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img alt="Window Application" border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhAi7Uz-E0hohBsZkxdLRZLpv1kaVwiNP-Mu4SqTcoOY8GDbVF-V9HEyhUaY1dTKn4XGTd9GZ9Sna6lz3W-vqg0FWLntVmE_4XNbHw9y-924WTUHYzN7h6tLdTIKSNnPyeAZ38et-12yPU/s1600/wfa.jpg" height="90" width="150" /></a></div>
<ol>
<li>It can also be called as Windows Application.</li>
<li>It‘s a collection of windows forms.</li>
</ol>
<br/><br/>
<div class="divh1">Form:</div>
<div style="float:right;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjPtoFbcP4IMfrGDU-9qJDN9w2kXbEMAMSTkIBCW4EGoqsLfAAtho2sBCJkuLDpoe0YGXzK8pBpuzYWJh2KwKjBJwDLzgpVhUK4i3sU_jmN8t-Of5jD3a_ixACYPBof793qQ3dSrqVaEFA/s1600/window+form.jpg" imageanchor="1" style="clear: right; float: right; margin-bottom: 1em; margin-left: 1em;"><img alt="Window Form Application" border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjPtoFbcP4IMfrGDU-9qJDN9w2kXbEMAMSTkIBCW4EGoqsLfAAtho2sBCJkuLDpoe0YGXzK8pBpuzYWJh2KwKjBJwDLzgpVhUK4i3sU_jmN8t-Of5jD3a_ixACYPBof793qQ3dSrqVaEFA/s1600/window+form.jpg" width="200px" height="120px" /></a></div>
<ol>
<li>The graphical container, which can contain the graphical controls like labels, textboxes, buttons, list boxes etc., is called as Form. It acts as container for the controls.</li>
<li>It is also called as a window.</li>
<li>It has the visual appearance with a title bar, icon, control box (with minimize button, maximize button and close button)</li>
</ol>
<div class="divh1">Creating a “Windows Forms Application” project:</div>
<div style="float:right;">
<table>
<tr>
<td>
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiACX8SXFjpL59bBtqjtB74BTRs2Pwpw-MQAbsyXcylEWrBAprAL0x1qM2BPl8sJeUB6qyFDRNg9o6gc6ukZSmBeH5MXmTMsTZLYXQhGGmJjUj7dlmAI6qRFy7BR15d45SGcZpBSdYYHGI/s1600/creating+window+form+project.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img alt="Creating Window Form Project" border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiACX8SXFjpL59bBtqjtB74BTRs2Pwpw-MQAbsyXcylEWrBAprAL0x1qM2BPl8sJeUB6qyFDRNg9o6gc6ukZSmBeH5MXmTMsTZLYXQhGGmJjUj7dlmAI6qRFy7BR15d45SGcZpBSdYYHGI/s1600/creating+window+form+project.jpg" height="120" width="200" /></a></td>
</tr>
<tr>
<td>
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhkg0UFEQBCVZrTY7sum3W6tYrnKa9kQQHi2gyyqzM5Ki_lla3ppBUV7iw5J-3aghYJC4KFyLM_xRF1FIZ6TmCNYWgELXktTpJqROM0bNBFezdIE85hKhhCO2-P7A_GhADzZ7hZvbN-g14/s1600/window+form+project.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img alt="Create Window Form" border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhkg0UFEQBCVZrTY7sum3W6tYrnKa9kQQHi2gyyqzM5Ki_lla3ppBUV7iw5J-3aghYJC4KFyLM_xRF1FIZ6TmCNYWgELXktTpJqROM0bNBFezdIE85hKhhCO2-P7A_GhADzZ7hZvbN-g14/s1600/window+form+project.jpg" height="120" width="200" /></a></td>
</tr>
</table></div>
<ol>
<li>Open Microsoft Visual Studio 2010.</li>
<li>Click on ―> File ―> New ―> Project.</li>
<li>Select the language as Visual C#.</li>
<li>Select the project type as Windows Forms Application.</li>
<li>Enter the name and location of the project.</li>
<li>Click on OK.</li>
<li>Then it will create a windows forms application, along with a form, named Form1.</li>
<li>Then the screen looks like this:</li>
</ol>
<div style="float:left;"><b>Next : </b><a href="http://microsoft-csharp-net.blogspot.com/2014/03/development-of-form.html">Development of Form</a></div>
<div align="center">
<script type="text/javascript">
( function() {
if (window.CHITIKA === undefined) { window.CHITIKA = { 'units' : [] }; };
var unit = {"calltype":"async[2]","publisher":"jayalaxmi0044","width":550,"height":250,"sid":"Chitika Default","color_button":"10404c","color_button_text":"ffffff"};
var placement_id = window.CHITIKA.units.length;
window.CHITIKA.units.push(unit);
document.write('<div id="chitikaAdBlock-' + placement_id + '"></div>');
}());
</script>
<script type="text/javascript" src="//cdn.chitika.net/getads.js" async></script>
</div>
</div>fdfsdfhttp://www.blogger.com/profile/08780252268386268059noreply@blogger.com0tag:blogger.com,1999:blog-6427703763785525312.post-47901075528627155892014-03-24T10:09:00.002-07:002015-06-24T02:01:55.693-07:00LINQ<div dir="ltr" style="text-align: left;" trbidi="on">
<div class="divh1"> LINQ </div><br/>
<ol>
<li>LINQ stands for "Language Integrated Query".</li>
<li>This concept is introduced in .NET Framework 3.5.</li>
<li>This is a query writing technology.</li>
<li>This is most useful while working large amount of data in the live projects.</li>
</ol>
<div class="divh1">INTRODUCTION:</div>
<ol>
<li>In relational database system, data is organized in the form of tables, on which you can write SQL queries to retrieve the required data according to the requirement in the application.</li>
<li>But you can‘t write a query on the non-database data, which in the form of objects in the application. There, you can write the queries using the new concept called "LINQ".</li>
<li>You can write queries on arrays, objects, databases and XML using LINQ.</li>
<li>Note: Before writing the LINQ queries, you should import the System.Linq namespace..</li>
</ol>
The following example shows a small demo on LINQ:<br/>
<div class="divh1">PROGRAM FOR LINQ TO ARRAYS</div>
<pre class="brush:csharp;">
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace LINQtoArrayDemo
{
class Program
{
static void Main(string[] args)
{
//data source
int[] numbers = { 2, 12, 10, 5, 15, 4, 62 };
//ling query
IEnumerable<int> result = from n in numbers where n <= 10 select n;
//output
foreach (var x in result)
Console.WriteLine(x);
Console.Read();
}
}
}
</pre>
<p>In the above application, the array contains few numbers. After executing the query, you got only the numbers, which are less than 10. In this manner, you can execute the queries on data sets (after learning ADO.NET) also.</p>
<div class="divh1"> LINQ SYNTAX: </div>
<br/>
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgXrAFlA6Twuy7FEUhyphenhyphenAtjVgf4uvV3kOtsPBfmcNYcd5QT5oPk30g-9fF1vsYDdkFL16quzQ2Ujj0AeNp7E9gUOkei3C3zIOJEDBSxrCtqDDgonEdZBcGniGT0NY5pMblNDRo3ywDZ7_1c/s1600/Linq+Sytax.jpg" imageanchor="1" ><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgXrAFlA6Twuy7FEUhyphenhyphenAtjVgf4uvV3kOtsPBfmcNYcd5QT5oPk30g-9fF1vsYDdkFL16quzQ2Ujj0AeNp7E9gUOkei3C3zIOJEDBSxrCtqDDgonEdZBcGniGT0NY5pMblNDRo3ywDZ7_1c/s200/Linq+Sytax.jpg" width="450px" height="30px"/></a>
<div style="float:right;">
<script type="text/javascript">
( function() {
if (window.CHITIKA === undefined) { window.CHITIKA = { 'units' : [] }; };
var unit = {"calltype":"async[2]","publisher":"jayalaxmi0044","width":300,"height":250,"sid":"Chitika Default","color_button":"10404c","color_button_text":"ffffff"};
var placement_id = window.CHITIKA.units.length;
window.CHITIKA.units.push(unit);
document.write('<div id="chitikaAdBlock-' + placement_id + '"></div>');
}());
</script>
<script type="text/javascript" src="//cdn.chitika.net/getads.js" async="async"></script>
</div>
<p>THE ABOVE SYNTAX CONSISTS OF 7 CLAUSES.</p>
<ol>
<li>from clause</li>
<li>in clause</li>
<li>let clause</li>
<li>where clause</li>
<li>orderby clause</li>
<li>select clause</li>
<li>group by clause</li>
<li>Mandatory clauses:</li>
<li>from clause</li>
<li>in clause</li>
<li>select clause</li>
</ol>
<div class="divh1"> CLAUSE </div>
<p>Def of Clause: A part of the query.</p>
<div class="divh1">UNDERSTANDING CLAUSES:</div>
<ol>
<li><b>from clause:</b> This is used to specify the iteration variable name. This acts as alias name for the data source.</li>
<li><b>in clause:</b> This is used to specify the main data source for the query.</li>
<li><b>let clause (optional):</b> This is used to declare a new identifier with a value, that is to be used during the query execution.</li>
<li><b>where clause (optional):</b> This is most frequently used optional clause, using which you can specify the condition in the query.</li>
<li><b>orderby clause (optional):</b> This is used to specify the sorting expression if required.</li>
<li><b>select clause:</b> This is used to specify the object, which is required in the query results.</li>
<li><b>group by (optional):</b> This is similar to ―group by‖ clause in SQL. This retrieves grouped data, based on a column.</li>
</ol>
<p><b>Note: </b> The result of a LINQ query should be assigned into a IEnumerable<data type> type variable. IEnumerable is an interface.</p>
<span style="color:red;">Library: System.Collections.Generic.IEnumerable</span>
<div class="divh1">PROGRAM FOR LINQ TO OBJECTS </div>
<pre class="brush:csharp;">
Student.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace LINQtoObjectsDemo
{
class Student
{
//fields
public int StudentID;
public string Name;
public string Course;
public int Marks;
//constructor
public Student(int StudentID, string Name, string Course, int Marks)
{
this.StudentID = StudentID;
this.Name = Name;
this.Course = Course;
this.Marks = Marks;
}
}
}
Program.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace LINQtoObjectsDemo
{
class Program
{
static void Main(string[] args)
{
//data source
Student[] stu = { new Student(101, "Prakash", "MBA", 765),
new Student(102, "Pradeep", "MBA", 471),
new Student(103, "Pushpa", "Msc", 590),
new Student(104, "Purna", "MCA", 223),
new Student(105, "Purnima", "MCA", 450)};
//linq query with where clause
IEnumerable<Student> result1 = from s in stu where s.Course == "MCA" select s; Console.WriteLine("MCA Students:");
foreach (Student r in result1)
Console.WriteLine(r.StudentID + ", " + r.Name + ", " + r.Course + ", " + r.Marks);
//linq query with compound where clause
IEnumerable<Student> result2 = from s in stu where s.Name.EndsWith("a") && s.Marks>=400 && s.Marks<=600 select s;
Console.WriteLine("\nStudents whose name ends with 'a', and marks is >=400 and <=600:");
foreach (Student r in result2)
Console.WriteLine(r.StudentID + ", " + r.Name + ", " + r.Course + ", " + r.Marks);
//linq query with let and where clauses
IEnumerable<Student> result3 = from s in stu let avg = s.Marks / 10 where avg < 35 select s;
Console.WriteLine("\nFailed Students:");
foreach (Student r in result3)
Console.WriteLine(r.StudentID + ", " + r.Name + ", " + r.Course + ", " + r.Marks);
//linq query with orderby clause
IEnumerable<Student> result4 = from s in stu orderby s.Marks select s;
Console.WriteLine("\nStudents (sort on marks):");
foreach (Student r in result4)
Console.WriteLine(r.StudentID + ", " + r.Name + ", " + r.Course + ", " + r.Marks);
//linq query with orderby clause (descending)
IEnumerable<Student> result5 = from s in stu orderby s.Marks descending select s;
Console.WriteLine("\nStudents (sort on marks - descending):");
foreach (Student r in result5)
Console.WriteLine(r.StudentID + ", " + r.Name + ", " + r.Course + ", " + r.Marks);
//linq query with group clause
IEnumerable<IGrouping<string,Student>> result6 = from s in stu group s by s.Course;
Console.WriteLine("\nStudents with grouping:");
foreach (IGrouping<string, Student> StuGrp in result6)
{
Console.WriteLine(StuGrp.Key + ":");
foreach (Student r in StuGrp)
Console.WriteLine(" " + r.StudentID + ", " + r.Name + ", " + r.Course + ", " + r.Marks);
}
Console.Read();
}
}
}
</pre>
<div align="center">
<script type="text/javascript">
( function() {
if (window.CHITIKA === undefined) { window.CHITIKA = { 'units' : [] }; };
var unit = {"calltype":"async[2]","publisher":"jayalaxmi0044","width":550,"height":250,"sid":"Chitika Default","color_button":"10404c","color_button_text":"ffffff"};
var placement_id = window.CHITIKA.units.length;
window.CHITIKA.units.push(unit);
document.write('<div id="chitikaAdBlock-' + placement_id + '"></div>');
}());
</script>
<script type="text/javascript" src="//cdn.chitika.net/getads.js" async></script>
</div>
<br /></div>fdfsdfhttp://www.blogger.com/profile/08780252268386268059noreply@blogger.com0tag:blogger.com,1999:blog-6427703763785525312.post-29959216391770893582014-03-09T09:30:00.000-07:002015-03-15T14:08:35.144-07:00Break Point<div dir="ltr" style="text-align: left;" trbidi="on">
<div style="float: right;">
<a href="http://microsoft-csharp-net.blogspot.com/2014/03/debug.html">EventLog</a>
<a href="http://microsoft-csharp-net.blogspot.in/2014/03/break-point.html">Break Point</a>
</div><br/>
<div class="divh1">Break Point</div><br/>
<div style="text-align: center;">
<script type="text/javascript">
( function() {
if (window.CHITIKA === undefined) { window.CHITIKA = { 'units' : [] }; };
var unit = {"calltype":"async[2]","publisher":"jayalaxmi0044","width":468,"height":180,"sid":"Chitika Default","color_button":"10404c","color_button_text":"ffffff"};
var placement_id = window.CHITIKA.units.length;
window.CHITIKA.units.push(unit);
document.write('<div id="chitikaAdBlock-' + placement_id + '"></div>');
}());
</script>
<script type="text/javascript" src="//cdn.chitika.net/getads.js" async></script>
</div>
<p>
<b>Bug:</b> : An error.<br/>
<b>Debugging: Removing the bugs.</p>
<p>
NET offers more features for debugging. To start with the .NET application debugging, you should create the break points.
</p>
<div style="float:right;">
<table>
<tr>
<td>
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEguIEhfNaL8XFcPIa4tCTl42trqdPdeJNBNTnWVJCFf-yyPpvs-I-L3buEZ90J4uBlGK3DcyvScGqKSEn-vRYfdrNlaSLmG-u4MbriGQT3mEtp6lK1SHJrg8gBrFZEsCNNnzwoB_v8B_Qc/s1600/BreakPoint.jpg" imageanchor="1" ><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEguIEhfNaL8XFcPIa4tCTl42trqdPdeJNBNTnWVJCFf-yyPpvs-I-L3buEZ90J4uBlGK3DcyvScGqKSEn-vRYfdrNlaSLmG-u4MbriGQT3mEtp6lK1SHJrg8gBrFZEsCNNnzwoB_v8B_Qc/s200/BreakPoint.jpg" /></a>
</td>
</tr>
<tr>
<td>
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhyVhT6Y8BoLuvKoOosO5TLooWyBxvlVo0zJgYUKNSuTYs4bbavFJsGwdOZ6dyX6wocHCVoQxvuUNJv54rY-g4trUAyvbCJFK_8PtcMvOFv-Agna89oDQrSepIHK97Dvv05ZXXLtHVDlxY/s1600/Demo+of+BreakPoint.jpg" imageanchor="1" ><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhyVhT6Y8BoLuvKoOosO5TLooWyBxvlVo0zJgYUKNSuTYs4bbavFJsGwdOZ6dyX6wocHCVoQxvuUNJv54rY-g4trUAyvbCJFK_8PtcMvOFv-Agna89oDQrSepIHK97Dvv05ZXXLtHVDlxY/s200/Demo+of+BreakPoint.jpg" /></a>
</td>
</tr>
</table>
</div>
<ol>
<li>
<b><span style="color:Red;">Definition of Break Point:</span></b> A break point is a point in the program, where the application execution control pauses until you press F10 key. In the code, that line is highlighted with red color.</li>
<li><b><span style="color:Red;"> Creating a break point: </span></b> Just click on the left side margin of the required line.</li>
<li><b><span style="color:red;">Running the Application with Break Points: </span></b> Just press F5 key. The application will be executed normally. But whenever the execution control reaches to the break point line, automatically the execution will be paused and the break point line will be highlighted with yellow color. To continue wit h the execution to the next statement, press “F10” key.</li>
<li><b><span style="color:red;">Observing the values of variables or objects: </span></b> While you are executing the application with break points, to know the current value of any variable or object, just place the mouse pointer over it.</li>
</ol>
<div class="divh1"> Immediate window </div>
<br/>
<table>
<tr>
<td>
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhST-vdmt6lDmEveLCchfGP0cxib5S1_j-oVL5pRn8L1hesLex4C_UknxSZa2lSgqq9hyO2bbOwMUh9VJpSNqnMIMYJG6A2g6-UcqsixMr0k6tHwGxqzAjplJIxTOEap6nLlrXmAoCNKQA/s1600/Immediate+Window.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhST-vdmt6lDmEveLCchfGP0cxib5S1_j-oVL5pRn8L1hesLex4C_UknxSZa2lSgqq9hyO2bbOwMUh9VJpSNqnMIMYJG6A2g6-UcqsixMr0k6tHwGxqzAjplJIxTOEap6nLlrXmAoCNKQA/s1600/Immediate+Window.jpg" width="300px" height="250px"/></a></td>
<td>
<script type="text/javascript">
( function() {
if (window.CHITIKA === undefined) { window.CHITIKA = { 'units' : [] }; };
var unit = {"calltype":"async[2]","publisher":"jayalaxmi0044","width":300,"height":250,"sid":"Chitika Default","color_button":"10404c","color_button_text":"ffffff"};
var placement_id = window.CHITIKA.units.length;
window.CHITIKA.units.push(unit);
document.write('<div id="chitikaAdBlock-' + placement_id + '"></div>');
}());
</script>
<script type="text/javascript" src="//cdn.chitika.net/getads.js" async></script>
</td>
</tr>
</table>
<ol>
<li>The Immediate window resides at bottom side of Visual Studio IDE. It will automatically appear at run time. If not, press Ctrl + Alt + I.</li>
<li>This window is used to know the current values of the required variables, objects or data members, which is not possible to find the value by just placing the mouse pointer over it.</li>
</ol>
<div class="divh1">Locals window</div>
<div>
<ul style="text-align: left;">
<li>It automatically displays all the current local variables along with their values.</li>
<li>To open this window, while running the application, get into the Visual Studio and press Ctrl+D and the L.</li>
</ul>
<div style="float: right;">
<a href="http://microsoft-csharp-net.blogspot.com/2014/03/debug.html">EventLog</a>
<a href="http://microsoft-csharp-net.blogspot.in/2014/03/break-point.html">Break Point</a>
</div>
<div align="center">
<script type="text/javascript">
( function() {
if (window.CHITIKA === undefined) { window.CHITIKA = { 'units' : [] }; };
var unit = {"calltype":"async[2]","publisher":"jayalaxmi0044","width":550,"height":250,"sid":"Chitika Default","color_button":"10404c","color_button_text":"ffffff"};
var placement_id = window.CHITIKA.units.length;
window.CHITIKA.units.push(unit);
document.write('<div id="chitikaAdBlock-' + placement_id + '"></div>');
}());
</script>
<script type="text/javascript" src="//cdn.chitika.net/getads.js" async></script>
</div>
</div>
</div>fdfsdfhttp://www.blogger.com/profile/08780252268386268059noreply@blogger.com0tag:blogger.com,1999:blog-6427703763785525312.post-73839878550449399572014-03-09T09:13:00.001-07:002015-03-15T14:21:45.564-07:00Debug<div dir="ltr" style="text-align: left;" trbidi="on">
<div style="float: right;">
<a href="http://microsoft-csharp-net.blogspot.in/2014/03/debug.html">Event Log</a>
<a href="http://microsoft-csharp-net.blogspot.com/2014/03/break-point.html">Break Point</a>
</div><br/>
<div class="divh1"> EventLog</div><br/>
<div style="text-align: center;">
<script type="text/javascript">
( function() {
if (window.CHITIKA === undefined) { window.CHITIKA = { 'units' : [] }; };
var unit = {"calltype":"async[2]","publisher":"jayalaxmi0044","width":468,"height":180,"sid":"Chitika Default","color_button":"10404c","color_button_text":"ffffff"};
var placement_id = window.CHITIKA.units.length;
window.CHITIKA.units.push(unit);
document.write('<div id="chitikaAdBlock-' + placement_id + '"></div>');
}());
</script>
<script type="text/javascript" src="//cdn.chitika.net/getads.js" async></script>
</div>
<br/>
<ol>
<li>EventLog is a service, offered by Microsoft Windows.</li>
<li>It is used to store the exceptions / warnings / any messages permanently, even though the application is closed.</li>
<li>Let us imagine you have done a live project and issue it to the client.</li>
<li>At run time there may be so many exceptions. But after few days, you went to the client location, and want to know what kind of run time errors were coming in your application.</li>
<li>Then no information is available with you.</li>
<li>So, in this case, you require some thing, that stores the exceptions information automatically, for further information, which helps you while you want to debug your application and develop a next version.</li>
<li>That kind of service is EventLog.</li>
<li>To open EventLog and view the current events: Start –> Control Panel –> Administrative Tools –> Event Viewer.</li>
</ol>
<table>
<tr>
<td>
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgpGbI1EkUPK27GxdaTn8wplHYBMDFztW9poEHTrEytVSZ2GK07FsElyVcyt4NDIIhyUlNVCUOFNR48csID9F-WsX8MKc8CSYnzv4nJgOox6krHaC8BcnJmJZIOPtYwfIHRau0fuJznzE4/s1600/EventLog.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgpGbI1EkUPK27GxdaTn8wplHYBMDFztW9poEHTrEytVSZ2GK07FsElyVcyt4NDIIhyUlNVCUOFNR48csID9F-WsX8MKc8CSYnzv4nJgOox6krHaC8BcnJmJZIOPtYwfIHRau0fuJznzE4/s1600/EventLog.jpg" width="300px" height="250px" /></a></td>
<td>
<script type="text/javascript">
( function() {
if (window.CHITIKA === undefined) { window.CHITIKA = { 'units' : [] }; };
var unit = {"calltype":"async[2]","publisher":"jayalaxmi0044","width":300,"height":250,"sid":"Chitika Default","color_button":"10404c","color_button_text":"ffffff"};
var placement_id = window.CHITIKA.units.length;
window.CHITIKA.units.push(unit);
document.write('<div id="chitikaAdBlock-' + placement_id + '"></div>');
}());
</script>
<script type="text/javascript" src="//cdn.chitika.net/getads.js" async></script>
</td>
</tr>
</table>
<p><b>Writing a new entry programmatically:</b><br />
<span style="color:Red;">System.Diagnostics.EventLog.WriteEntry("project name", "message", EventLogEntryType.Error);</span></p>
<br />
<div class="divh1"> Program of Event Log </div>
<pre class="brush:csharp;">
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Diagnostics;
namespace EventLogDemo
{
class Program
{
static void Main(string[] args)
{
try
{
string filename = "c:\\sample.txt";
StreamReader sr = new StreamReader(filename);
string content = sr.ReadToEnd();
Console.WriteLine("The file content is:\n");
Console.WriteLine(content);
}
catch (Exception ex)
{
string EventMsg = ex.Message + "\n\n" + ex.StackTrace;
EventLog.WriteEntry("My Sample Project 1.0", EventMsg,
EventLogEntryType.Error);
Console.WriteLine(ex.Message);
}
finally
{
Console.WriteLine("Press any key to exit..");
Console.Read();
}
}
}
}
</pre>
<div style="float: right;">
<a href="http://microsoft-csharp-net.blogspot.in/2014/03/debug.html">Event Log</a>
<a href="http://microsoft-csharp-net.blogspot.com/2014/03/break-point.html">Break Point</a>
</div><br/>
<div align="center">
<script type="text/javascript">
( function() {
if (window.CHITIKA === undefined) { window.CHITIKA = { 'units' : [] }; };
var unit = {"calltype":"async[2]","publisher":"jayalaxmi0044","width":550,"height":250,"sid":"Chitika Default","color_button":"10404c","color_button_text":"ffffff"};
var placement_id = window.CHITIKA.units.length;
window.CHITIKA.units.push(unit);
document.write('<div id="chitikaAdBlock-' + placement_id + '"></div>');
}());
</script>
<script type="text/javascript" src="//cdn.chitika.net/getads.js" async></script>
</div>
</div>fdfsdfhttp://www.blogger.com/profile/08780252268386268059noreply@blogger.com0tag:blogger.com,1999:blog-6427703763785525312.post-68443659197615256972014-03-09T09:02:00.000-07:002015-03-15T14:30:56.347-07:00Anonymous Method & Speech Translator<div dir="ltr" style="text-align: left;" trbidi="on">
<div style="text-align: center;">
<script type="text/javascript">
( function() {
if (window.CHITIKA === undefined) { window.CHITIKA = { 'units' : [] }; };
var unit = {"calltype":"async[2]","publisher":"jayalaxmi0044","width":468,"height":180,"sid":"Chitika Default","color_button":"10404c","color_button_text":"ffffff"};
var placement_id = window.CHITIKA.units.length;
window.CHITIKA.units.push(unit);
document.write('<div id="chitikaAdBlock-' + placement_id + '"></div>');
}());
</script>
<script type="text/javascript" src="//cdn.chitika.net/getads.js" async></script>
</div>
This is used to create a method, without any name.<br/>
<div class="divh1"> Syntax: </div>
<pre class="brush:csharp;">
delegate()
{
//some code
}
</pre>
<br/>
<div class="divh1">PROGRAM OF ANONYMOUS METHOD</div>
<pre class="brush:csharp;">
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
namespace AnonymousMethodsDemo
{
class ThreadingDemo
{
public void Display(string name)
{
Thread th1 = new Thread(delegate()
{
while (true)
{
Console.WriteLine("Welcome to " + name);
Thread.Sleep(500);
}
});
th1.Start();
}
}
class Program
{
static void Main(string[] args)
{
string name;
Console.WriteLine("Enter your name:");
name = Console.ReadLine();
ThreadingDemo td = new ThreadingDemo();
td.Display(name);
Console.Read();
}
}
}
</pre>
<br/>
<div class="divh1"> SPEECH TRANSLATION</div>
<ol>
<li>This is to translate the text as speech.</li>
<li>This makes us to listen a voice from the speakers that reads some specified text.</li>
<li>Library: System.Speech.Synthesis.SpeechSynthesizer</li>
<li>This class used to speak the required text through the speakers.</li>
</ol>
<div class="divh1"> Implementation:</div>
<ol>
<li>
Create the object of SpeechSynthesizer class:</li>
<span style="color:red;"> SpeechSynthesizer ss = new SpeechSynthesizer(); </span>
<li> Set the volume (1 to 100):</li>
<span style="color:red;"> ss.Volume = n; </span>
<li> Set the speed of speaking (-10 to +10):</li>
<span style="color:red;"> ss.Rate = n;</span>
<li>Change the voice gender and age:</li>
<span style="color:red;"> ss.SelectVoiceByHints(VoiceGender.xxxx, VoiceAge.xxxx);</span>
<li> Speak the text:</li>
<span style="color:red;"> ss.SpeakAsync(―message‖);</span>
</ol><br/>
<div class="divh1"> PROGRAM OF SPEECH TRANSLATOR</div>
<pre class="brush:csharp;">
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Speech.Synthesis;
namespace SpeechTranslationDemo
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Enter text to speak:");
string TextToSpeak = Console.ReadLine();
SpeechSynthesizer ss = new SpeechSynthesizer();
ss.Volume = 100; //1 to 100
ss.Rate = -3; // -10 to +10
ss.SelectVoiceByHints(VoiceGender.Female, VoiceAge.Child);
ss.SpeakAsync(TextToSpeak);
Console.Read();
}
}
}
</pre>
<div align="center">
<script type="text/javascript">
( function() {
if (window.CHITIKA === undefined) { window.CHITIKA = { 'units' : [] }; };
var unit = {"calltype":"async[2]","publisher":"jayalaxmi0044","width":550,"height":250,"sid":"Chitika Default","color_button":"10404c","color_button_text":"ffffff"};
var placement_id = window.CHITIKA.units.length;
window.CHITIKA.units.push(unit);
document.write('<div id="chitikaAdBlock-' + placement_id + '"></div>');
}());
</script>
<script type="text/javascript" src="//cdn.chitika.net/getads.js" async></script>
</div>
</div>fdfsdfhttp://www.blogger.com/profile/08780252268386268059noreply@blogger.com2tag:blogger.com,1999:blog-6427703763785525312.post-62956917923022388212014-03-09T08:50:00.000-07:002015-03-15T15:01:31.399-07:00Memory Management<div dir="ltr" style="text-align: left;" trbidi="on">
<div class="divh1"> Memory Management </div><br/>
<div style="text-align: center;">
<script type="text/javascript">
( function() {
if (window.CHITIKA === undefined) { window.CHITIKA = { 'units' : [] }; };
var unit = {"calltype":"async[2]","publisher":"jayalaxmi0044","width":468,"height":180,"sid":"Chitika Default","color_button":"10404c","color_button_text":"ffffff"};
var placement_id = window.CHITIKA.units.length;
window.CHITIKA.units.push(unit);
document.write('<div id="chitikaAdBlock-' + placement_id + '"></div>');
}());
</script>
<script type="text/javascript" src="//cdn.chitika.net/getads.js" async></script>
</div>
<div>
<div style="float:right;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgC-gMLvwBKtFeSLXwET8tYtf6azEXnuf7ZMSN7EdB5dFQIJ_SyCDy9NyQ9hSHOFTm3ogFIbmsCAFC2BZAs1938ifj9pDq06OpuhA7FYGEquxrvBcMgxmGcYg4rI4k3IKz3qBgb5sgIYmk/s1600/RAM.jpg" imageanchor="1" ><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgC-gMLvwBKtFeSLXwET8tYtf6azEXnuf7ZMSN7EdB5dFQIJ_SyCDy9NyQ9hSHOFTm3ogFIbmsCAFC2BZAs1938ifj9pDq06OpuhA7FYGEquxrvBcMgxmGcYg4rI4k3IKz3qBgb5sgIYmk/s200/RAM.jpg" /></a>
</div>
<ol>
<li>Every application requires some amount of memory to run.</li>
<li>That memory will be allocated in the primary memory (RAM).</li>
<li>For every variable, individual memory will be allocated.</li>
<li>The RAM contains two memory locations.
<ul><li>--> Stack</li>
<li>--> Heap</li></ul></li>
<li>Now, we need to understand, where the application memory is getting allocated in the RAM.</li>
<li>The storage area in the RAM depends on the data type that you are using for declaring the variable in the program.</li>
<li>The data types are two types in C#
<ul><li>--> Value Types</li>
<li>--> Reference Types</li></ul></li>
</ol>
</div>
<div>
<div class="divh1"> Value Type</div>
<div style="float:right;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiW33YA5Ga8UlRvf6IxoyfziHE1ZYDdt8Ug2riREnHJ_LpYq4Yuwf5R-y1bNhiHRlyu1i70Apz2oYehQrVY9oRO6RyjgvYenj4S-H6kB3kq6hIEhBYmFKcFQOU_GkW32TlxnuF8eGs5u2I/s1600/value+type.jpg" imageanchor="1" ><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiW33YA5Ga8UlRvf6IxoyfziHE1ZYDdt8Ug2riREnHJ_LpYq4Yuwf5R-y1bNhiHRlyu1i70Apz2oYehQrVY9oRO6RyjgvYenj4S-H6kB3kq6hIEhBYmFKcFQOU_GkW32TlxnuF8eGs5u2I/s200/value+type.jpg" /></a></div>
<ol>
<li><b>Def: </b> Whenever a data type is designed based on a structure, it can be called as Value Type.</li>
<li>All the standard data types built based on structures.</li>
<li>You can see the list of data types and respective structures here:</li>
<li>So finally, the following are value types in C#:
<ul>
<li>Structures</li>
<li>Enumerations</li>
<li>sbyte, byte, short, ushort, int, uint, long, ulong, float, double, decimal, bool, char, decimal, DateTime </li>
</ul></li>
<li><b>Note 1: </b>The value types can‘t be inherited.</li>
<li><b>Note 2: </b>All the value types (structures and enumerations), are derived from a common base class called System.ValueType.</li>
</ol>
</div>
<div class="divh1"> REFERENCE TYPES:</div>
<ol>
<li><b>Def: </b>Whenever a data type is designed based on a class, it can be called as Reference Type.</li>
<li>The following are the reference types in C#:
<ul><li>Classes</li>
<li>Interfaces</li>
<li>String, Object</li></ul></li>
<li>Reference types support inheritance. </li>
<li>The Value Type variables will be allocated in the Stack.</li>
<li>The Reference Type variables (objects) will be allocated in the Heap.</li>
</ol>
<div class="divh1"> THE “SYSTEM.OBJECT” CLASS:</div>
<div style="float:right;">
<script type="text/javascript">
( function() {
if (window.CHITIKA === undefined) { window.CHITIKA = { 'units' : [] }; };
var unit = {"calltype":"async[2]","publisher":"jayalaxmi0044","width":300,"height":600,"sid":"Chitika Default","color_button":"10404c","color_button_text":"ffffff"};
var placement_id = window.CHITIKA.units.length;
window.CHITIKA.units.push(unit);
document.write('<div id="chitikaAdBlock-' + placement_id + '"></div>');
}());
</script>
<script type="text/javascript" src="//cdn.chitika.net/getads.js" async="async"></script>
</div>
<ul>
<li>This class acts as super class for all other classes (pre-defined / user-defined classes).</li>
<li>So, it can be called as Ultimate base class.</li>
<li>The Object class offers the following methods</li>
</ul>
<div valign="top">
<table width="auto;" height="500px">
<tr>
<td>
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjtA_oO7GmpOZGqfJUuhJb235XLJYD9h-pdWVjwA0N73GIgSdoqVDXDk1pkZYV-7ktVu5EbMtqFUWiYbQ5hTtYR0ti1yMLF8GIjZKevOtUwyXDmOKxCe4kaZV-kjiUN1IEyPkc8JLrmiEY/s1600/System.object+class.jpg" imageanchor="1" ><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjtA_oO7GmpOZGqfJUuhJb235XLJYD9h-pdWVjwA0N73GIgSdoqVDXDk1pkZYV-7ktVu5EbMtqFUWiYbQ5hTtYR0ti1yMLF8GIjZKevOtUwyXDmOKxCe4kaZV-kjiUN1IEyPkc8JLrmiEY/s200/System.object+class.jpg" width="300px" height="250px"/></a>
</td>
</tr>
<tr>
<td>
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEieLq0zkG0Ptru5n4yFyH2mfXDG-rDjMAMcaCxZTJ6aOKIyIbRkQ3_3cYP7a4SBuDh2sMuEgHnkG4dTs6RhsdW2KsT2CgsDeJnq0hNgPQJL20TkpHEVadC6QYDUYgMkGZ7hYEWpD3gOW8A/s1600/System.object+table.jpg" imageanchor="1" ><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEieLq0zkG0Ptru5n4yFyH2mfXDG-rDjMAMcaCxZTJ6aOKIyIbRkQ3_3cYP7a4SBuDh2sMuEgHnkG4dTs6RhsdW2KsT2CgsDeJnq0hNgPQJL20TkpHEVadC6QYDUYgMkGZ7hYEWpD3gOW8A/s200/System.object+table.jpg" width="300px" height="250px"/></a>
</td>
</tr>
</table>
</div>
<div class="divh1"> PROGRAM OF SYSTEM.OBJECT CLASS </div>
<pre class="brush:csharp;">
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ObjectClassMethods
{
class Program
{
static void Main(string[] args)
{
int x = 100;
int y = 100;
Console.WriteLine("x is " + x);
Console.WriteLine("y is " + y);
Console.WriteLine();
if (x.Equals(y))
Console.WriteLine("x is equal to y");
else
Console.WriteLine("x is not equal to y");
Console.WriteLine("\nx is the type of " + x.GetType());
string s = x.ToString();
Console.WriteLine("\nThe integer value after converting into string is: " + s);
Console.Read();
}
}
}
</pre>
<div class="divh1"> GARBAGE COLLECTOR:</div>
<div style="float:right;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjl2t5Mc0YODQrEjHflaRDhTvXcYb3ANy4hoRswDuX13ZA20STrrSVuBJaMueHNnU2N-LUD0FIdP9nedgUNcP6JXTczYCTQdNmqQJNKP4ZGUX3vktZQSBbKKkOr2b_8UTTdnYlDXge4IWg/s1600/GC.jpg" imageanchor="1" ><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjl2t5Mc0YODQrEjHflaRDhTvXcYb3ANy4hoRswDuX13ZA20STrrSVuBJaMueHNnU2N-LUD0FIdP9nedgUNcP6JXTczYCTQdNmqQJNKP4ZGUX3vktZQSBbKKkOr2b_8UTTdnYlDXge4IWg/s200/GC.jpg" height="200px" width="120px"/></a>
</div>
<ol>
<li>This is one of the components of CLR (Common Language Runtime).</li>
<li>This component is dedicated for de-allocating the un-used memory of the application, automatically.</li>
<li>This uses Mark and Compact algorithm for clearing the un-used memory.</li>
<li><b>Mark:</b> Markup the un-used objects and push those objects towards up.</li>
<li><b>Compact: </b>Clear the marked objects memory.</li>
</ol>
<p><b>Note:</b> The above functionality is in-built in Garbage collector component. Anyhow, there is a provision for the programmer to command the garbage collector to perform garbage collection at run time, programmatically. Then use the following method from System.GC class.
<span style="color:Red;">Syn: System.GC.Collect();</span></p>
<div align="center">
<br/>
<script type="text/javascript">
( function() {
if (window.CHITIKA === undefined) { window.CHITIKA = { 'units' : [] }; };
var unit = {"calltype":"async[2]","publisher":"jayalaxmi0044","width":550,"height":250,"sid":"Chitika Default","color_button":"10404c","color_button_text":"ffffff"};
var placement_id = window.CHITIKA.units.length;
window.CHITIKA.units.push(unit);
document.write('<div id="chitikaAdBlock-' + placement_id + '"></div>');
}());
</script>
<script type="text/javascript" src="//cdn.chitika.net/getads.js" async></script>
</div>
</div>fdfsdfhttp://www.blogger.com/profile/08780252268386268059noreply@blogger.com0tag:blogger.com,1999:blog-6427703763785525312.post-2795685097284395312014-03-09T08:22:00.001-07:002015-03-15T15:44:26.545-07:00Assembly<div dir="ltr" style="text-align: left;" trbidi="on">
<div style="float: right;">
<a href="http://microsoft-csharp-net.blogspot.in/2014/03/assembly.html">Assembly</a>
<a href="http://microsoft-csharp-net.blogspot.com/2014/03/implementation-of-shared-assemblies.html">Implementation of Share Assemblies</a>
<a href="http://microsoft-csharp-net.blogspot.com/2014/03/shared-assemblies.html%20Done">Shared Assemblies</a></div>
<br/>
<div class="divh1"> Assembly</div><br/>
<div style="text-align: center;">
<script async="async" type="text/javascript">
( function() {
if (window.CHITIKA === undefined) { window.CHITIKA = { 'units' : [] }; };
var unit = {"calltype":"async[2]","publisher":"jayalaxmi0044","width":468,"height":180,"sid":"Chitika Default","color_button":"10404c","color_button_text":"ffffff"};
var placement_id = window.CHITIKA.units.length;
window.CHITIKA.units.push(unit);
document.write('<div id="chitikaAdBlock-' + placement_id + '"></div>');
}());
</script>
<script type="text/javascript" src="//cdn.chitika.net/getads.js" async="async"></script>
</div>
<ul>
<li><b>Def: </b>An assembly is the container of compiled code of .NET applications.</li>
<li>It contains the code in MSIL (Microsoft Intermediate Language) language.</li>
<li>At run time, it will be compiled by CLR‘s JIT compiler into machine language.</li>
<li>The assembly file (with .exe or .dll extension) will be generated in the project folder \bin folder, after compilation.</li>
</ul>
<div class="divh1"> TYPES OF ASSEMBLIES (BASED ON EXTENSION):</div>
<ol>
<li>Executable Assemblies / Process Assemblies / Private Assemblies (with .EXE extension)
<p>a. This is generated with</p>
<ul>
<li>Console Applications</li>
<li>Smart Device Applications</li>
<li>Windows Applications</li>
</ul>
</li>
<p>b. These files are ready for execution. You can execute those by simply double clicking.</p>
<p><b>Limitation:</b> The code in this assembly is not accessible from other projects.</p></li>
<li> Library Assemblies / Re-usable Assemblies / Shared Assemblies (with .DLL extension)
<p>i. This is generated with</p>
<ul>
<li>Class Library</li>
<li>Windows Forms Control Library</li>
</ul>
<p>ii. These are non-executable files.</p>
<p><b>Advantage: </b>The code is this assembly is accessible from other projects.</p></li>
</ol>
<div class="divh1"> Overview of “Class Library” Project</div>
<ul>
<li>A class library project is meant for the development of Shared Assemblies.</li>
<li>The shared assemblies are re-usable in other applications also. </li>
<li>That means the class library‘s code is re-usable in other applications, whenever required.</li>
<li>Class library project contains only user-defined classes.</li>
<li>Whenever the class library project is compiled, a library assembly file (with .DLLextension) will be generated in the ―bin\Debug folder.</li>
<li>The class library project can‘t be executed directly unlike console applications, windows applications etc.</li>
</ul>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjw9zzZ1-fjR6uw1aiZPlXHG1O3q4ASa6aFd8hC8CFIX9xxx4WYsKF9Kr1sD0JPECktvl6DB3s22fp2acW4JuN87hVXqTki4OvM0mkT0k1y7DcN6dh18O-y53GyF5n1fiufGK2A01gf6e8/s1600/Class+Library.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img alt="Class Library" border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjw9zzZ1-fjR6uw1aiZPlXHG1O3q4ASa6aFd8hC8CFIX9xxx4WYsKF9Kr1sD0JPECktvl6DB3s22fp2acW4JuN87hVXqTki4OvM0mkT0k1y7DcN6dh18O-y53GyF5n1fiufGK2A01gf6e8/s1600/Class+Library.jpg" /></a></div>
<div class="divh1"> Global Assembly Cache (GAC): </div>
<p>All the shared assemblies should be saved in the GAC. GAC offers the following advantages.</p>
<ul>
<li>Unique identification of the shared assemblies.</li>
<li>Avoids the DLL hell (replacement of an assembly related to one application, by another application).</li>
<li>Faster accessibility.</li>
</ul>
<p>To view the currently installed assemblies in the GAC, open the following folder <b>C:\windows\assembly</b> The above folder is able to contain multiple dll files with same name, with different versions.</p>
<div class="divh1"> STRONG NAME KEYS (SNK): </div>
<p>The strong name key is a file, which acts as a unique identifier, for the shared assemblies, stored in the GAC. In other words, GAC recogniz es the assembly with this strong name only.</p>
<div style="float: right;">
<a href="http://microsoft-csharp-net.blogspot.in/2014/03/assembly.html">Assembly</a>
<a href="http://microsoft-csharp-net.blogspot.com/2014/03/implementation-of-shared-assemblies.html">Implementation of Share Assemblies</a>
<a href="http://microsoft-csharp-net.blogspot.com/2014/03/shared-assemblies.html%20Done">Shared Assemblies</a></div>
<br/>
<div align="center">
<script async="async" type="text/javascript">
( function() {
if (window.CHITIKA === undefined) { window.CHITIKA = { 'units' : [] }; };
var unit = {"calltype":"async[2]","publisher":"jayalaxmi0044","width":550,"height":250,"sid":"Chitika Default","color_button":"10404c","color_button_text":"ffffff"};
var placement_id = window.CHITIKA.units.length;
window.CHITIKA.units.push(unit);
document.write('<div id="chitikaAdBlock-' + placement_id + '"></div>');
}());
</script>
<script type="text/javascript" src="//cdn.chitika.net/getads.js" async="async"></script>
</div>
</div>fdfsdfhttp://www.blogger.com/profile/08780252268386268059noreply@blogger.com0tag:blogger.com,1999:blog-6427703763785525312.post-6273230200149551772014-03-09T08:21:00.001-07:002015-03-15T15:53:44.544-07:00Implementation of Shared Assemblies<div dir="ltr" style="text-align: left;" trbidi="on">
<div style="float: right;">
<a href="http://microsoft-csharp-net.blogspot.com/2014/03/assembly.html">Assembly</a>
<a href="http://microsoft-csharp-net.blogspot.in/2014/03/implementation-of-shared-assemblies.html">Implementation of Shared Assemblies</a>
<a href="http://microsoft-csharp-net.blogspot.com/2014/03/shared-assemblies.html">Shared Assemblies</a>
</div><br/>
<div class="divh1"> Implementation of Shared Assemblies</div><br/>
<div style="text-align: center;">
<script async="async" type="text/javascript">
( function() {
if (window.CHITIKA === undefined) { window.CHITIKA = { 'units' : [] }; };
var unit = {"calltype":"async[2]","publisher":"jayalaxmi0044","width":468,"height":180,"sid":"Chitika Default","color_button":"10404c","color_button_text":"ffffff"};
var placement_id = window.CHITIKA.units.length;
window.CHITIKA.units.push(unit);
document.write('<div id="chitikaAdBlock-' + placement_id + '"></div>');
}());
</script>
<script type="text/javascript" src="//cdn.chitika.net/getads.js" async="async"></script>
</div>
<h2><i style="font-weight: normal;"><span style="color: red;">Create a Class Library Project.</span></i></h2>
<ul>
<li>Create a new Class Library project.</li>
<li>Write the required code in the project.</li>
</ul>
<h2><i style="font-weight: normal;"><span style="color: red;">Create a strong name key.</span></i></h2>
<ul>
<li>Right click on the project in the Solution Explorer and choose Properties.</li>
<li>In the project properties, select the check box Sign the assembly.</li>
<li>In the Choose a strong name key file‖ drop down, select <New> option.</li>
<li>In the Create strong name key‖ dialog box, enter the name of the strong name key file.</li>
<li>If password security is not required, uncheck the Protect my key file with a password checkbox.</li>
<li>Click on OK.</li>
</ul>
<h2><i style="font-weight: normal;"><span style="color: red;">Customize the “Assembly Information” (AssemblyInfo.cs).</span></i></h2>
<ul>
<li>This is optional step.</li>
<li>To change the additional details of the assembly like displayed name, version, company, copy right, description etc., open “AssemblyInfo.cs” file from the Properties folder in the Solution Explorer.</li>
</ul>
<h2><span style="color: red;"><i style="font-weight: normal;">Generate the DLL File.</i></span></h2>
<ul>
<li>Build the class library project.</li>
<li>Then the .dll‖ file will be generated in the bin\debug folder of your class library project.</li>
</ul>
<h2><span style="color: red; font-weight: normal;"><i>Write the assembly into GAC (Global Assembly Cache).</i></span></h2>
<ul>
<li>Open the following folder.</li>
<span style="color:red;"><b>C:\Windows\Assembly</b></span>
<li>Drag and drop the ―.DLL file‖ from ―bin\Debug‖ folder into the</li>
<span style="color:red;"><b>c:\windows\assembly folder.</b></span>
<li>After dragging, the name of your shared assembly will appear in the existing list.</li>
<li>Now, the shared assembly is ready. The rest of your work involved with the usage of the shared assembly.</li>
</ul>
<div class="divh1"> Invoke the Shared Assembly.</div>
<ul>
<li>Create the executable project (Console application / windows application).</li>
<li>Click on Project – Add Reference.</li>
<li>Click on Browse tab.</li>
<li>Open the class library project‘s bin\Debug folder.</li>
<li>Select the dll file and click on OK.</li>
<li>Then the reference of the selected shared assembly will be added to the current project.</li>
<li>Then you can construct objects for the required class in the class library and perform required activities on that.</li>
</ul>
<div style="float: right;">
<a href="http://microsoft-csharp-net.blogspot.com/2014/03/assembly.html">Assembly</a>
<a href="http://microsoft-csharp-net.blogspot.in/2014/03/implementation-of-shared-assemblies.html">Implementation of Shared Assemblies</a>
<a href="http://microsoft-csharp-net.blogspot.com/2014/03/shared-assemblies.html">Shared Assemblies</a>
</div><br/>
<div align="center">
<script async="async" type="text/javascript">
( function() {
if (window.CHITIKA === undefined) { window.CHITIKA = { 'units' : [] }; };
var unit = {"calltype":"async[2]","publisher":"jayalaxmi0044","width":550,"height":250,"sid":"Chitika Default","color_button":"10404c","color_button_text":"ffffff"};
var placement_id = window.CHITIKA.units.length;
window.CHITIKA.units.push(unit);
document.write('<div id="chitikaAdBlock-' + placement_id + '"></div>');
}());
</script>
<script type="text/javascript" src="//cdn.chitika.net/getads.js" async="async"></script>
</div>
</div>fdfsdfhttp://www.blogger.com/profile/08780252268386268059noreply@blogger.com0tag:blogger.com,1999:blog-6427703763785525312.post-11670270998100520662014-03-09T08:21:00.000-07:002015-03-15T16:14:04.873-07:00Shared Assemblies<div dir="ltr" style="text-align: left;" trbidi="on">
<div style="float:right;">
<a href="http://microsoft-csharp-net.blogspot.com/2014/03/assembly.html">Assembly</a>
<a href="http://microsoft-csharp-net.blogspot.com/2014/03/implementation-of-shared-assemblies.html">Implementation of Shared Assemblies</a>
<a href="http://microsoft-csharp-net.blogspot.in/2014/03/shared-assemblies.html">Shared Assemblies</a>
</div><br/>
<div class="divh1"> Shared Assembly </div>
<div style="text-align: center;">
<script async="async" type="text/javascript">
( function() {
if (window.CHITIKA === undefined) { window.CHITIKA = { 'units' : [] }; };
var unit = {"calltype":"async[2]","publisher":"jayalaxmi0044","width":468,"height":180,"sid":"Chitika Default","color_button":"10404c","color_button_text":"ffffff"};
var placement_id = window.CHITIKA.units.length;
window.CHITIKA.units.push(unit);
document.write('<div id="chitikaAdBlock-' + placement_id + '"></div>');
}());
</script>
<script type="text/javascript" src="//cdn.chitika.net/getads.js" async="async"></script>
</div>
<h1>CREATE A CLASS LIBRARY PROJECT.</h1>
<ol>
<li>Open Visual Studio 2008.</li>
<li>Click on ― > File‖ ―> New ―> Project.</li>
<li>Select the language as ―> Visual C# and project template as ―> Class Library.</li>
<li>Enter the name as ―> SharedAssemblyLibrary.</li>
<li>Click on OK. It creates a new class library project. Initially it contains a new class called class1.</li>
<li>In the solution explorer, rename the class1.cs as "MyLibraryClass.cs”.</li>
<li>Then type the following code.</li>
</ol>
<div class="divh1"> PROGRAM FOR CLASS LIBRARY PROJECT </div>
<pre class="brush:csharp;">
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace SharedAssemblyLibrary
{
public class MyLibraryClass
{
public bool IsValidLogin(string Username, string Password)\
{
if (Username == "system" && Password == "manager")
return true;
else
return false;
}
}
}
</pre>
<div class="divh1"> CREATE A STRONG NAME KEY.</div>
<br/>
<div style="float:right;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhpixhk7eWMF3hUjdopBKpOrUFCsEiq4I1WfNnshJxIe44neDMo7mlYu1qhT3aI6Xm7CzBjoYKsbYqiV55BVwdCVqD40ywDRU7qwcEaQ2si3yFCucg5WJi0yJCkIB_UeocD4w-5ygxo-kk/s1600/Strong+Name.jpg" imageanchor="1" ><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhpixhk7eWMF3hUjdopBKpOrUFCsEiq4I1WfNnshJxIe44neDMo7mlYu1qhT3aI6Xm7CzBjoYKsbYqiV55BVwdCVqD40ywDRU7qwcEaQ2si3yFCucg5WJi0yJCkIB_UeocD4w-5ygxo-kk/s200/Strong+Name.jpg" width="250px" height="200px"/></a>
</div>
<ol>
<li>Right click on the project in the Solution Explorer and choose Properties.</li>
<li>In the project properties, select the check box Sign the assembly</li>
<li>In the Choose a strong name key file drop down, select <New> option.</li>
<li>In the Create strong name key‖ dialog box, enter the name of the strong name key file as “MyKeyFile”. </li>
<li>Uncheck the ―Protect my key file with a password‖ checkbox.</li>
<li>Click on OK. </li>
</ol>
<div class="divh1">CUSTOMIZE THE “ASSEMBLY INFORMATION” (ASSEMBLYINFO.CS).</div>
<p>Change the assembly version as “1.5.0.0”.</p>
<div class="divh1">GENERATE THE DLL FILE.</div>
<p>Build the class library project by clicking on ―Build‖ menu – ―Build Solution‖.</p>
<div class="divh1">WRITE THE ASSEMBLY INTO GAC (GLOBAL ASSEMBLY CACHE).</div>
<ul><li>Open the following folder</li>
<li>C:\Windows\Assembly</li>
<li>Drag and drop the “SharedAssemblyLibrary.DLL‖ file from ―bin\Debug‖ folder into the c:\windows\assembly folder.</li></ul>
<div class="divh1"> INVOKE THE SHARED ASSEMBLY.</div>
<div style="float:right;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiEb9EkGfoVQUMqeOZo7cc1M2mZwQQcVwYXgWou3350inHH2jAOz3PnpidGXQbrPgPh1CKRwCbyTk7VGFF9yIxEgMVOYBFUGixxiQsChhPW_06W_KfAWsy6esBEVaOzCn3b_6_-F3kr0lo/s1600/Shared+Asseblies.jpg" imageanchor="1" ><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiEb9EkGfoVQUMqeOZo7cc1M2mZwQQcVwYXgWou3350inHH2jAOz3PnpidGXQbrPgPh1CKRwCbyTk7VGFF9yIxEgMVOYBFUGixxiQsChhPW_06W_KfAWsy6esBEVaOzCn3b_6_-F3kr0lo/s200/Shared+Asseblies.jpg" width="250px" height="200px"/></a>
</div><br/><br/>
<ul valign="top">
<li>Create a new Console Application. Name: SharedAssemblyDemo</li>
<li>Click on Project ― Add Reference.</li>
<li>Click on Browse tab</li>
<li>From the class library project‘s bin\Debug‖ folder, select the “SharedAssemblyLibrary.dll file and click on OK. Then the .dll file reference will be added</li>
</ul>
<div class="divh1"> PROGRAM FOR SHARED ASSEMBLIES </div>
<pre class="brush:csharp;">
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using SharedAssemblyLibrary;
namespace SharedAssemblyDemo
{
class Program
{
static void Main(string[] args)
{
MyLibraryClass mlc = new MyLibraryClass();
string Username, Password;
Console.Write("Enter Username: ");
Username = Console.ReadLine();
Console.Write("Enter Password: ");
Password = Console.ReadLine();
bool result = mlc.IsValidLogin(Username, Password);
if (result == true)
Console.WriteLine("\nLogin successful!");
else
Console.WriteLine("\nInvalid Username / Password!");
Console.Read();
}
}
}
</pre>
<div style="float:right;">
<a href="http://microsoft-csharp-net.blogspot.com/2014/03/assembly.html">Assembly</a>
<a href="http://microsoft-csharp-net.blogspot.com/2014/03/implementation-of-shared-assemblies.html">Implementation of Shared Assemblies</a>
<a href="http://microsoft-csharp-net.blogspot.in/2014/03/shared-assemblies.html">Shared Assemblies</a>
</div><br/>
<div align="center">
<script async="async" type="text/javascript">
( function() {
if (window.CHITIKA === undefined) { window.CHITIKA = { 'units' : [] }; };
var unit = {"calltype":"async[2]","publisher":"jayalaxmi0044","width":550,"height":250,"sid":"Chitika Default","color_button":"10404c","color_button_text":"ffffff"};
var placement_id = window.CHITIKA.units.length;
window.CHITIKA.units.push(unit);
document.write('<div id="chitikaAdBlock-' + placement_id + '"></div>');
}());
</script>
<script type="text/javascript" src="//cdn.chitika.net/getads.js" async="async"></script>
</div>
<br /></div>fdfsdfhttp://www.blogger.com/profile/08780252268386268059noreply@blogger.com0tag:blogger.com,1999:blog-6427703763785525312.post-89033060674835353092014-03-09T07:31:00.000-07:002015-03-15T16:33:35.865-07:00Multi Threading & Thread State<div dir="ltr" style="text-align: left;" trbidi="on">
<div style="float: right;">
<a href="http://microsoft-csharp-net.blogspot.in/2014/03/multi-threading-thread-state.html">Multi Threading</a>
<a href="http://microsoft-csharp-net.blogspot.com/2014/03/thread-state.html">Thread State</a></div><br/>
<div class="divh1"> Multi Threading </div><br/>
<div style="text-align: center;">
<script async="async" type="text/javascript">
( function() {
if (window.CHITIKA === undefined) { window.CHITIKA = { 'units' : [] }; };
var unit = {"calltype":"async[2]","publisher":"jayalaxmi0044","width":468,"height":180,"sid":"Chitika Default","color_button":"10404c","color_button_text":"ffffff"};
var placement_id = window.CHITIKA.units.length;
window.CHITIKA.units.push(unit);
document.write('<div id="chitikaAdBlock-' + placement_id + '"></div>');
}());
</script>
<script type="text/javascript" src="//cdn.chitika.net/getads.js" async="async"></script>
</div>
<ul>
<li>Multi Threading is one of the rich features of .NET applications.</li>
<li>Using this feature, the user is able to create multi-threaded applications.</li>
<li>This concept is introduced in VC++. This is also supported by Java.</li>
<li><b>Definition of Multi Threading:</b> The ability of an application that maintains multiple threads at run time.</li>
<li><b>Definition of Thread:</b> The thread is a sub process (part of the process). That means it has some code to execute.</li>
<li><b>Advantage of Multi-Threading:</b> Using multi threading‖, you can break a complex task in a single application into multiple threads that execute independently and simultaneously.</li>
<li>In other words, multi threading is the sub form of multi tasking.</li>
<li>Before starting with the implementation of Multi Threading, you should recollect the concept of Multi-Tasking.<li>
</ul>
<div class="divh1"> MULTI TASKING:</div>
<ul>
<li><b>Def:</b> Ability of the OS, that is able to perform more than one task, at-a-time (simultaneously) is called as Multi-Tasking.</li>
<li>As a part of this, OS allocates the CPU clock (CPU capacity) for each task.</li>
</ul>
<p><b>Note:</b> Just like multi-tasking, OS allocates the CPU clock for each thread.</p>
<div class="divh1"> THREADING ARCHITECTURE </div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhK6NDdklgjaBBz8MuE7Jn60oM8C9WFkJWwb8yVDbj2jOpABGVYM0X4j2LYvI0Su447-qCE1_1hh4RjY0fnpueBsVMQG3thKlBUqd1kJKhbrp2kzVAqIYbnp7y1mzLl5xjecRNkAkBzJ6o/s1600/Thread+Architectur.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhK6NDdklgjaBBz8MuE7Jn60oM8C9WFkJWwb8yVDbj2jOpABGVYM0X4j2LYvI0Su447-qCE1_1hh4RjY0fnpueBsVMQG3thKlBUqd1kJKhbrp2kzVAqIYbnp7y1mzLl5xjecRNkAkBzJ6o/s1600/Thread+Architectur.jpg" /></a></div>
<br/>
<div class="divh1"> Implementation of Multi Threading:</div>
<p>.NET Framework offers a namespace called “System.Threading” for implementation of multi threading.<br/>
</p>
<b>Library:</b><span style="color: red;"> System.Threading.Thread</span><br/>
This class object represents a thread.
<ul>
<li><b>Import the API:</b></li>
<span style="color: red;">using System.Threading;</span>
<li><b>Create the Thread Object:</b></li>
<span style="color: red;">Thread th = new Thread(method name);</span>
<li>Start the Thread:</li>
<span style="color: red;">th.Start()</span>
</ul>
<div class="divh1"> Program for Multi-Threading </div>
<pre class="brush:csharp;">
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
namespace SimpleThreadingDemo
{
class ThreadingDemo
{
private void FirstMethod()
{
for (int i = 1; i <= 300; i++)
Console.Write("i=" + i + " ");
}
private void SecondMethod()
{
for (int j = 1; j <= 300; j++)
Console.Write("j=" + j + " ");
}
public void Display()
{
Thread th1 = new Thread(FirstMethod);
Thread th2 = new Thread(SecondMethod);
th1.Start();
th2.Start();
}
}
class Program
{
static void Main(string[] args)
{
ThreadingDemo td = new ThreadingDemo();
td.Display();
Console.Read();
}
}
}
</pre>
<div style="float: right;">
<a href="http://microsoft-csharp-net.blogspot.in/2014/03/multi-threading-thread-state.html">Multi Threading</a>
<a href="http://microsoft-csharp-net.blogspot.com/2014/03/thread-state.html">Thread State</a></div><br/>
<div align="center">
<script async="async" type="text/javascript">
( function() {
if (window.CHITIKA === undefined) { window.CHITIKA = { 'units' : [] }; };
var unit = {"calltype":"async[2]","publisher":"jayalaxmi0044","width":550,"height":250,"sid":"Chitika Default","color_button":"10404c","color_button_text":"ffffff"};
var placement_id = window.CHITIKA.units.length;
window.CHITIKA.units.push(unit);
document.write('<div id="chitikaAdBlock-' + placement_id + '"></div>');
}());
</script>
<script type="text/javascript" src="//cdn.chitika.net/getads.js" async="async"></script>
</div>
/div>
</div>fdfsdfhttp://www.blogger.com/profile/08780252268386268059noreply@blogger.com0tag:blogger.com,1999:blog-6427703763785525312.post-83144579261097936872014-03-09T07:09:00.000-07:002015-03-15T16:44:01.553-07:00Thread State<div dir="ltr" style="text-align: left;" trbidi="on">
<div style="float:right;">
<a href="http://microsoft-csharp-net.blogspot.in/2014/03/multi-threading-thread-state.html">Multi Threading</a>
<a href="http://microsoft-csharp-net.blogspot.in/2014/03/thread-state.html">Thread State</a>
</div><br/>
<div class="divh1"> Thread State</div>
<div style="text-align: center;">
<script async="async" type="text/javascript">
( function() {
if (window.CHITIKA === undefined) { window.CHITIKA = { 'units' : [] }; };
var unit = {"calltype":"async[2]","publisher":"jayalaxmi0044","width":468,"height":180,"sid":"Chitika Default","color_button":"10404c","color_button_text":"ffffff"};
var placement_id = window.CHITIKA.units.length;
window.CHITIKA.units.push(unit);
document.write('<div id="chitikaAdBlock-' + placement_id + '"></div>');
}());
</script>
<script type="text/javascript" src="//cdn.chitika.net/getads.js" async="async"></script>
</div>
<div>
The thread state specifies the current status of the thread. Sometimes, the thread automatically switches from one state to another state automatically; at some other times, you can switch its state by using the methods offered by Thread class.</div>
<div>
The following diagram called Thread Life Cycle describes the different states of a thread.</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj60GAV2HKuqcqWTNMLlShSONDSFVNH_YSW6Bajjx6w-IadtqagO8mKwZ7FHRAVdEHUxh2j-R8JAPB6OFlnOwZIF5jV7oeo472AZbHlLUZHy9poBCnX2PJYlw2D6UtMX03439w1TBvnm8g/s1600/Multi+Thread+Life+Cycle.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj60GAV2HKuqcqWTNMLlShSONDSFVNH_YSW6Bajjx6w-IadtqagO8mKwZ7FHRAVdEHUxh2j-R8JAPB6OFlnOwZIF5jV7oeo472AZbHlLUZHy9poBCnX2PJYlw2D6UtMX03439w1TBvnm8g/s1600/Multi+Thread+Life+Cycle.jpg" /></a></div>
<div>
<ol style="text-align: left;">
<li>Ready: This is the initial state. The thread object is created.</li>
<li>Running: The thread is currently being executed.</li>
<li>Sleeping: The thread is temporarily paused. .NET framework offers automatic switching between Running and Sleeping states, when other threads are executed.</li>
<li>Suspended: The thread is temporarily suspended (paused). It will be continued, when you call Resume() method.</li>
<li>Dead: The thread was closed; it can‘t be restarted or continued.</li>
</ol>
</div>
<div class="divh1"> Thread class methods:</div>
<div>
<ul style="text-align: left;">
<li><b><span style="color: red;">thobj.Start() : </span></b>This method starts-up the thread execution.</li>
<li><b><span style="color: red;">Thread.Sleep(mille sec) :</span> </b>This method puts the thread under Sleeping state, up to a certain no. of mille seconds. When the given no. of mille seconds are completed, automatically the thread execution will be continued.</li>
<li><b style="color: red;">thobj.Suspend() : </b>This is similar to Sleep() method, but here, no time limit will be given. That means whenever the Suspend() method is called, the thread will be put under Suspended state, until the Resume() method is called.</li>
<li><b><span style="color: red;">thobj.Resume() : </span> </b>This is to continue the thread execution that is under Suspended state. This method won‘t work if the thread is not under Suspended state.</li>
<li><b><span style="color: red;">thobj.Abort() :</span> </b>This is close the thread execution completely, at any time. Once, if the Abort() method is called, the thread can‘t be started or resumed. This is the end of every thread life cycle</li>
</ul>
</div>
<div class="divh1"> Program of Thread State </div>
<pre class="brush:csharp;">
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
namespace ThreadLifeCycleDemo
{
class ThreadingDemo
{
private void FirstMethod()
{
for (int i = 1; i <= 50; i++)
{
Console.Write("i=" + i + " ");
Thread.Sleep(1000);
}
}
private void SecondMethod()
{
for (int j = 1; j <= 50; j++)
{
Console.Write("j=" + j + " ");
Thread.Sleep(1000);
if (j == 20)
th1.Suspend();
else if (j == 30)
th1.Resume();
}
}
Thread th1, th2;
public void Display()
{
th1 = new Thread(FirstMethod);
th2 = new Thread(SecondMethod);
th1.Start();
th2.Start();
}
}
class Program
{
static void Main(string[] args)
{
ThreadingDemo td = new ThreadingDemo();
td.Display();
Console.Read();
}
}
}
</pre>
<div style="float:right;">
<a href="http://microsoft-csharp-net.blogspot.in/2014/03/multi-threading-thread-state.html">Multi Threading</a>
<a href="http://microsoft-csharp-net.blogspot.in/2014/03/thread-state.html">Thread State</a>
</div><br/>
<div align="center">
<script async="async" type="text/javascript">
( function() {
if (window.CHITIKA === undefined) { window.CHITIKA = { 'units' : [] }; };
var unit = {"calltype":"async[2]","publisher":"jayalaxmi0044","width":550,"height":250,"sid":"Chitika Default","color_button":"10404c","color_button_text":"ffffff"};
var placement_id = window.CHITIKA.units.length;
window.CHITIKA.units.push(unit);
document.write('<div id="chitikaAdBlock-' + placement_id + '"></div>');
}());
</script>
<script type="text/javascript" src="//cdn.chitika.net/getads.js" async="async"></script>
</div>
</div>fdfsdfhttp://www.blogger.com/profile/08780252268386268059noreply@blogger.com0tag:blogger.com,1999:blog-6427703763785525312.post-40718120227214501952014-03-09T06:45:00.002-07:002015-03-16T00:49:19.375-07:00Exception Class<div dir="ltr" style="text-align: left;" trbidi="on">
<div style="float: right;">
<a href="http://microsoft-csharp-net.blogspot.com/2014/03/exception-handling-exception-class.html">Exception Handling</a>
<a href="http://microsoft-csharp-net.blogspot.in/2014/03/exception-class.html">Exception Class</a></div><br/>
<div class="divh1"> Exception Class</div>
<div style="text-align: center;">
<script async="async" type="text/javascript">
( function() {
if (window.CHITIKA === undefined) { window.CHITIKA = { 'units' : [] }; };
var unit = {"calltype":"async[2]","publisher":"jayalaxmi0044","width":468,"height":180,"sid":"Chitika Default","color_button":"10404c","color_button_text":"ffffff"};
var placement_id = window.CHITIKA.units.length;
window.CHITIKA.units.push(unit);
document.write('<div id="chitikaAdBlock-' + placement_id + '"></div>');
}());
</script>
<script type="text/javascript" src="//cdn.chitika.net/getads.js" async="async"></script>
</div>
<ul style="text-align: left;">
<li>Already you know that C# recognizes the exception as an object.</li>
<li>To declare the exception object, we have used a class called System.Exception, in the previous examples.</li>
<li>The Exception class recognizes any type of exceptions. In order to catch the particular type of error, C# provides other exceptional classes. Some of them are given here.</li>
</ul>
<br/>
<table border="1" bordercolor="#FFCC00" cellpadding="0" cellspacing="0" style="background-color: #ffffcc; width: auto;">
<tbody>
<tr>
<td align="center" style="height: auto; width: auto;"><b><span style="color: red;">Exception Class</span></b></td>
<td align="center" style="height: auto; width: auto;"><b><span style="color: red;">Description</span></b></td>
</tr>
<tr>
<td class="tdtext">System.OverflowException</td>
<td class="tdtext">Occurs when a large value is assigned to a variable, which is not fit in that variable.</td>
</tr>
<tr>
<td class="tdtext">System.FormatException / System.InvalidCastException</td>
<td class="tdtext">Occurs when the casting is failed from one data type of another data type.</td>
</tr>
<tr>
<td class="tdtext">System.DivideByZeroException</td>
<td class="tdtext">Occurs when any number is divided by 0.</td>
</tr>
<tr>
<td class="tdtext">System.IndexOutOfRangeException</td>
<td class="tdtext">Occurs when an index is accessed in out of range.</td>
</tr>
<tr>
<td class="tdtext">System.InsufficientMemoryException</td>
<td class="tdtext">Occurs when there is no sufficient memory in RAM for the execution of the application.</td>
</tr>
<tr>
<td class="tdtext">System.IO.FileNotFoundException</td>
<td class="tdtext">Occurs when a non-existing file is accessed.</td>
</tr>
<tr>
<td class="tdtext">System.IO.DirectoryNotFoundException</td>
<td class="tdtext">Occurs when a non-existing directory is accessed.</td>
</tr>
<tr>
<td class="tdtext">System.IO.FileLoadException</td>
<td class="tdtext">Occurs when any error occurred during the opening of any file.</td>
</tr>
<tr>
<td class="tdtext">System.IO.IOException</td>
<td class="tdtext">Occurs when any error occurred during file read or writing.</td>
</tr>
<tr>
<td class="tdtext">System.Threading.ThreadInterruptedException</td>
<td class="tdtext">Occurs when any error occurred during the execution of the thread.</td>
</tr>
<tr>
<td class="tdtext">System.Threading.ThreadStartException</td>
<td class="tdtext">Occurs when any error occurred while starting the thread.</td>
</tr>
<tr>
<td class="tdtext">System.InvalidOperationException</td>
<td class="tdtext">Occurs when any error occurred while opening the database connection.</td>
</tr>
<tr>
<td class="tdtext">System.Data.OleDb.OleDbException</td>
<td class="tdtext">Occurs when any error occurred while performing query or non-query transactions on OleDb databases.</td>
</tr>
<tr>
<td class="tdtext">System.Data.SqlClient.SqlException</td>
<td class="tdtext">Occurs when any error occurred while performing query or non-query transactions on SqlServer database.</td>
</tr>
<tr>
<td class="tdtext">System.EntryPointNotFoundException</td>
<td class="tdtext">Occurs when you try to run the application, without defining any entry point (main() method).</td>
</tr>
<tr>
<td class="tdtext">System.InvalidTimeZoneException</td>
<td class="tdtext">Occurs when the system has an invalid time zone setting the date & time settings.</td>
</tr>
</tbody>
</table>
<br/>
<div class="divh1"> PROGRAM OF EXCEPTION CLASS </div>
<pre class="brush:csharp;">
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ExceptionDemo3
{
class Program
{
static void Main(string[] args)
{
try
{
int n1, n2, n3;
Console.WriteLine("Enter first value:");
n1 = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("Enter second value:");
n2 = Convert.ToInt32(Console.ReadLine());
n3 = n1 / n2;
Console.WriteLine("Result is: " + n3);
}
catch (DivideByZeroException ex)
{
Console.WriteLine("Can't divide the number with zero.");
}
Console.Read();
}
}
}
</pre>
<p><b>Note:</b> If you want to handle more than one type of exception for the same try block, then you
need to write multiple catch blocks</p>
<div class="divh1">PROGRAM FOR MULTIPLE CATCH BLOCK </div>
<pre class="brush:csharp;">
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ExceptionDemo4
{
class Program
{
static void Main(string[] args)
{
try
{
int n1, n2, n3;
Console.WriteLine("Enter first value:");
n1 = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("Enter second value:");
n2 = Convert.ToInt32(Console.ReadLine());
n3 = n1 / n2;
Console.WriteLine("Result is: " + n3);
}
catch (DivideByZeroException ex)
{
Console.WriteLine("This is divide by zero exception.");
}
catch (OverflowException ex)
{
Console.WriteLine("This is overflow excpetion.");
}
catch (FormatException ex)
{
Console.WriteLine("This is invalid cast exception.");
}
Console.Read();
}
}
}
</pre>
<div style="float: right;">
<a href="http://microsoft-csharp-net.blogspot.com/2014/03/exception-handling-exception-class.html">Exception Handling</a>
<a href="http://microsoft-csharp-net.blogspot.in/2014/03/exception-class.html">Exception Class</a></div><br/>
<div align="center">
<script async="async" type="text/javascript">
( function() {
if (window.CHITIKA === undefined) { window.CHITIKA = { 'units' : [] }; };
var unit = {"calltype":"async[2]","publisher":"jayalaxmi0044","width":550,"height":250,"sid":"Chitika Default","color_button":"10404c","color_button_text":"ffffff"};
var placement_id = window.CHITIKA.units.length;
window.CHITIKA.units.push(unit);
document.write('<div id="chitikaAdBlock-' + placement_id + '"></div>');
}());
</script>
<script type="text/javascript" src="//cdn.chitika.net/getads.js" async="async"></script>
</div>
</div>fdfsdfhttp://www.blogger.com/profile/08780252268386268059noreply@blogger.com0tag:blogger.com,1999:blog-6427703763785525312.post-28352621850233506282014-03-09T06:33:00.000-07:002015-03-16T01:15:18.688-07:00Exception Handling & Exception Class<div dir="ltr" style="text-align: left;" trbidi="on">
<div style="float: center;">
<a href="http://microsoft-csharp-net.blogspot.in/2014/03/exception-handling-exception-class.html">Exception Handling</a>
<a href="http://microsoft-csharp-net.blogspot.com/2014/03/exception-class.html">Exception Class</a>
</div>
<div class="divh1"> Exception Handling</div><br/>
<div style="text-align: center;">
<script async="async" type="text/javascript">
( function() {
if (window.CHITIKA === undefined) { window.CHITIKA = { 'units' : [] }; };
var unit = {"calltype":"async[2]","publisher":"jayalaxmi0044","width":468,"height":180,"sid":"Chitika Default","color_button":"10404c","color_button_text":"ffffff"};
var placement_id = window.CHITIKA.units.length;
window.CHITIKA.units.push(unit);
document.write('<div id="chitikaAdBlock-' + placement_id + '"></div>');
}());
</script>
<script type="text/javascript" src="//cdn.chitika.net/getads.js" async="async"></script>
</div>
<ul>
<li>This is one of the major features of OOP languages like C++, VC++, VB.NET, C#.NET, Java etc.</li>
<li><b>Def: </b> The process of handling the run time exceptions" is called as "Exception handling".</li>
<p> Note: Exception = Run time error</p>
</ul>
<div class="divh1"> Types of Errors:</div>
<ol>
<li><b>Compile Time Errors:</b> The errors occurred after compiling the program, are called as compile time errors.</li>
<li><b>Run Time Errors:</b> The errors occurred during the execution of the program, are called as run time errors.</li>
</ol>
<div class="divh1"> Overview of Exception Handling:</div>
<ul>
<li>The exception may occur at run time, based on the mistake of the user / programmer / system problem also.</li>
<li>When exception is raised, automatically it leads to "abnormal application termination".</li>
<li>The cause of the exception may be anything; the project developer should take care about the exceptions.</li>
<li>As a part of this exception handling, the programmer has to display "particular error message" to the user.</li>
<li>Purpose of Exception Handling: To avoid "abnormal application termination", even though exception occurs.</li>
</ul>
<div class="divh1"> Types of Application Termination:</div>
<ul>
<li><span style="color: orange;">Normal Application Termination:</span> Whenever the program execution controls executes all the statements in the program and reaches to end of the code, the application will be terminated automatically. It can be called as Normal Application Termination.</li>
<li><b><span style="color: orange;">Abnormal Application Termination: </span></b> Whenever an exception occurred at run time, the application will be terminated automatically. It can be called as Abnormal Application Termination.If the application was terminated abnormally, if will be most inconvenience for the user. So being a programmer, you are responsible to avoid that kind of abnormal application termination, even though exception is occurred at run time</li>
</ul>
<div class="divh1"> Program of Exception Demo </div>
<pre class="brush:csharp;">
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ExceptionDemo1
{
class Program
{
static void Main(string[] args)
{
string[] Cities = { "Vijayawada", "New Delhi", "Banglore", "Hyderabad" };
Console.WriteLine(Cities[3]);
Console.WriteLine(Cities[4]); <!----Exception Raise----->
Console.Read();
}
}
}
</pre>
<p>
In the above code, the highlighted line contains an error, because it is trying to access an array element which is in out of range of the array. So, it leads to abnormal application termination at run time .</p>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEghxlqF7mj1MUkateOOPJam-0hv3d4dh2UNqhSuALzenVC1z1780Uqe_28O1g2FQQjU_WybLK4Aw56w1Ys1VIsNKtX0B4YBP_LJz84-0T6iLTnEBn0MCaSKrhJ0WP42OhqJipMxeO9SB3c/s1600/exception+Handling.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img alt="exception handling" border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEghxlqF7mj1MUkateOOPJam-0hv3d4dh2UNqhSuALzenVC1z1780Uqe_28O1g2FQQjU_WybLK4Aw56w1Ys1VIsNKtX0B4YBP_LJz84-0T6iLTnEBn0MCaSKrhJ0WP42OhqJipMxeO9SB3c/s1600/exception+Handling.jpg" height="459" width="640" /></a></div>
<pre class="brush:csharp;">
/*Syntax Of Exception
------------------------------*/
try
{
<!--Code Here-->
}
Catch (Exception ex)
{
<!--Code Here-->
}
Finally
{
<!--Code Here-->
}
</pre>
<div class="divh1"> try block:</div>
<div style="flaot:right;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj0oHXbKljTLAJBppkJ3El2G3R34qiB3sAoDzXeYjFJcagTrpKAZ4S6SDVq59hnRt6WLEd6_qz65Hl3I-Iq5YYHhAoA8VJL-3_McgmJPhYmbEB2GkuUuu12fLW2ECU-TrB9CaonxXeEqWU/s1600/try.jpg" imageanchor="1" style="clear: right; float: right; margin-bottom: 1em; margin-left: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj0oHXbKljTLAJBppkJ3El2G3R34qiB3sAoDzXeYjFJcagTrpKAZ4S6SDVq59hnRt6WLEd6_qz65Hl3I-Iq5YYHhAoA8VJL-3_McgmJPhYmbEB2GkuUuu12fLW2ECU-TrB9CaonxXeEqWU/s1600/try.jpg" /></a></div>
<ul>
<li>The try block contains the actual code, which is to be executed.</li>
<li>After every try block, there should catch block without fail.</li>
<li>The system tries to execute the code in the try block.</li>
<li>During the execution, if any exception occurs, then the execution control automatically goes to catch block.</li>
<li>At the same time, the try block throws the exception to the catch block in the form of an object. That object is called as exception object.</li>
</ul>
<div class="divh1"> catch block:</div>
<div style="float:right;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiCF0mjcct2E2HhwnHmupH5S_B8N-2kMWc2mTrA__xRjMgVsLIq__Iqj1E0Ewnr3CJyQN6qgriC1fB84BjH5ZNtU0tHz9t4ONlNDjnLjtiXLk81HAMV-SKJOGSof2L6X81GlWJLWnT-OIc/s1600/catch+(exception+ex).jpg" imageanchor="1" style="clear: right; float: right; margin-bottom: 1em; margin-left: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiCF0mjcct2E2HhwnHmupH5S_B8N-2kMWc2mTrA__xRjMgVsLIq__Iqj1E0Ewnr3CJyQN6qgriC1fB84BjH5ZNtU0tHz9t4ONlNDjnLjtiXLk81HAMV-SKJOGSof2L6X81GlWJLWnT-OIc/s1600/catch+(exception+ex).jpg" /></a></div>
<ul>
<li>This is also known as error handler.</li>
<li>This is followed by the try block.</li>
<li>The catch block will be executed if any exception is occurred during the execution of try block.</li>
<li>The catch block contains necessary code which displays an error message to the user.</li>
<li>This receives the exception, thrown by the try block, in the form of an object. In the following syntax, ex is the Exception object. The Exception is the class for the exception object.</li>
<li><b>Library:</b><span style="color: red;"> System.Exception</span></li>
</ul>
<div class="divh1"> finally block:</div>
<div style="float:right;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgb8JG0zR4t0Ead7osreYkHo9jRvEHTV70TF63UfK_BiXQZ3LSGUhXwcUo7Mgm4KYPqCmiWSXgsm4qW7DGJ3B33lHNcD-YhhNoSBge1qm2OYo4OJGBXvCavzHkiEC53lGPhlEjZ7x47aXQ/s1600/Finally.jpg" imageanchor="1" style="clear: right; float: right; margin-bottom: 1em; margin-left: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgb8JG0zR4t0Ead7osreYkHo9jRvEHTV70TF63UfK_BiXQZ3LSGUhXwcUo7Mgm4KYPqCmiWSXgsm4qW7DGJ3B33lHNcD-YhhNoSBge1qm2OYo4OJGBXvCavzHkiEC53lGPhlEjZ7x47aXQ/s1600/Finally.jpg" /></a></div>
<ul>
<li>This block will be executed automatically and compulsorily, after executing try block / catch block.</li>
<li>That means even though exception is raised or not raised, the finally block will be executed without fail.</li>
<li>This is optional block. You can write the exception handling syntax only with try and catch blocks, without finally block.</li>
</ul>
<div class="divh1"> PROGRAM OF EXCEPTION HANDLIGN </div>
<pre class="brush:csharp;">
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ExceptionDemo2
{
class Program
{
static void Main(string[] args)
{
try
{
string[] Cities = { "Vijayawada", "New Delhi", "Banglore", "Hyderabad" };
Console.WriteLine(Cities[3]);
Console.WriteLine(Cities[4]);
}
catch (Exception ex)
{
Console.WriteLine("Error occurred.");
}
finally
{
Console.WriteLine("This is 'finally' block.");
Console.Read();
}
}
}
}
</pre>
<div class="divh1"> Types of Catch Block Messages:</div>
<p>
Already we have discussed that the catch block generates an error message, when an exception occurs. That error message can be of two types.</p>
<ol>
<li>User Defined Message</li>
<li>System Defined Message</li>
</ol>
<ol>
<li><b>User Defined Message: </b>Your own message can be written.
<ul><li> Error Occurred.</li>
<li> Operation is not successful. etc.</li></ul></li>
<li><b>System Defined Message:</b> The system provides the description of the error, so that you can print that on the output directly. To access the system defined message, you can use the exception object as follows:
<ul><li><b>Syn:</b><span style="color: red;">ex.Message</span></li></ul></li>
</ol>
<p><b>Example:</b></p>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgAqChHGcHD1QC5bLHhjQHM49rgbNU-S4nbmFCf7aWZHcUX3Pu3Nx5r_teDJtH3kDb7Z8O1Ty42RCnrHhXIhcWaIMGQgZOZ0dEoWhDqsPbv_wqwbKjJdcvqbBgsutbWBXRh4zYVu_SYUBI/s1600/exception+Handling+2.jpg" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgAqChHGcHD1QC5bLHhjQHM49rgbNU-S4nbmFCf7aWZHcUX3Pu3Nx5r_teDJtH3kDb7Z8O1Ty42RCnrHhXIhcWaIMGQgZOZ0dEoWhDqsPbv_wqwbKjJdcvqbBgsutbWBXRh4zYVu_SYUBI/s1600/exception+Handling+2.jpg" /></a><b style="color: blue;"><span style="background-color: #cccccc;"></span></b></div>
<div style="float: center;">
<a href="http://microsoft-csharp-net.blogspot.in/2014/03/exception-handling-exception-class.html">Exception Handling</a>
<a href="http://microsoft-csharp-net.blogspot.com/2014/03/exception-class.html">Exception Class</a>
</div>
<div align="center">
<script async="async" type="text/javascript">
( function() {
if (window.CHITIKA === undefined) { window.CHITIKA = { 'units' : [] }; };
var unit = {"calltype":"async[2]","publisher":"jayalaxmi0044","width":550,"height":250,"sid":"Chitika Default","color_button":"10404c","color_button_text":"ffffff"};
var placement_id = window.CHITIKA.units.length;
window.CHITIKA.units.push(unit);
document.write('<div id="chitikaAdBlock-' + placement_id + '"></div>');
}());
</script>
<script type="text/javascript" src="//cdn.chitika.net/getads.js" async="async"></script>
</div>
</div>fdfsdfhttp://www.blogger.com/profile/08780252268386268059noreply@blogger.com0tag:blogger.com,1999:blog-6427703763785525312.post-74926651219709661422014-03-09T05:46:00.000-07:002015-03-16T01:42:37.874-07:00Print Document Class<div dir="ltr" style="text-align: left;" trbidi="on">
<div style="float: right;">
<a href="http://microsoft-csharp-net.blogspot.com/2014/03/collections.html" style="text-decoration: underline;">Collection</a>
<a href="http://microsoft-csharp-net.blogspot.com/2014/03/collection-initializer.html" style="text-decoration: underline;">Collection Initializer</a>
<a href="http://microsoft-csharp-net.blogspot.in/2014/03/print-document-class.html">Printi Document Class</a>
</div>
<div class="divh1"> Print Document Class</div>
<div style="text-align: center;">
<script async="async" type="text/javascript">
( function() {
if (window.CHITIKA === undefined) { window.CHITIKA = { 'units' : [] }; };
var unit = {"calltype":"async[2]","publisher":"jayalaxmi0044","width":468,"height":180,"sid":"Chitika Default","color_button":"10404c","color_button_text":"ffffff"};
var placement_id = window.CHITIKA.units.length;
window.CHITIKA.units.push(unit);
document.write('<div id="chitikaAdBlock-' + placement_id + '"></div>');
}());
</script>
<script type="text/javascript" src="//cdn.chitika.net/getads.js" async="async"></script>
</div>
<p>
.NET supports to print any type of documents through the printer.<br/>
<b>Library:</b> <span style="color: red;">System.Drawing.Printing.PrintDocument</span><br/>
This class object represents a document (any type of file), that is ready to print.<br/>
<b>Note:</b> By default, System.Drawing assembly will not be linked with the Console applications. <br/>
That‘s why you need to add a reference to that as follows:<br/>
<ul>
<li>Click on ―> Project menu ―> Add Reference.</li>
<li>Select ―> System.Drawing assembly.</li>
<li>Click on OK. Then the System.Drawing assembly will be linked with the current project and it will be displayed in References folder in the Solution Explorer.</li>
</ul>
<div class="divh1"> Implementation:</div>
<ul>
<li><b>Import the namespace:</b>
<span style="color: red;"> using System.Drawing.Printing;</span></li>
<li><b>Construct the object:</b></li>
<span style="color: red;"> PrintDocument obj = new PrintDocument();</span></li>
<li><b>Assign the document name, that is to be printed:</b></li>
<span style="color: red;"> obj.DocumentName = file path to be printed;</span></li>
<li><b>Start Printing:</b></li>
<span style="color: red;"> obj.Print();</span></li>
</ul>
<div class="divh1"> PROGRAM FOR PRINT CLASS </div>
<pre class="brush:csharp;">
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing.Printing;
namespace PrintingDemo
{
class Program
{
static void Main(string[] args)
{
PrintDocument doc = new PrintDocument();
doc.DocumentName = "c:\\SampleDocument.doc";
doc.Print();
Console.WriteLine("Printing started...");
Console.Read();
}
}
}
</pre>
<div style="float: right;">
<a href="http://microsoft-csharp-net.blogspot.com/2014/03/collections.html" style="text-decoration: underline;">Collection</a>
<a href="http://microsoft-csharp-net.blogspot.com/2014/03/collection-initializer.html" style="text-decoration: underline;">Collection Initializer</a>
<a href="http://microsoft-csharp-net.blogspot.in/2014/03/print-document-class.html">Printi Document Class</a>
</div><br/>
<div align="center">
<script async="async" type="text/javascript">
( function() {
if (window.CHITIKA === undefined) { window.CHITIKA = { 'units' : [] }; };
var unit = {"calltype":"async[2]","publisher":"jayalaxmi0044","width":550,"height":250,"sid":"Chitika Default","color_button":"10404c","color_button_text":"ffffff"};
var placement_id = window.CHITIKA.units.length;
window.CHITIKA.units.push(unit);
document.write('<div id="chitikaAdBlock-' + placement_id + '"></div>');
}());
</script>
<script type="text/javascript" src="//cdn.chitika.net/getads.js" async="async"></script>
</div>
</div>fdfsdfhttp://www.blogger.com/profile/08780252268386268059noreply@blogger.com0tag:blogger.com,1999:blog-6427703763785525312.post-1118366095939591232014-03-09T05:44:00.002-07:002015-03-16T01:53:43.016-07:00Collections<div dir="ltr" style="text-align: left;" trbidi="on">
<div style="float:right;">
<a href="http://microsoft-csharp-net.blogspot.in/2014/03/collections.html">Collection</a>
<a href="http://microsoft-csharp-net.blogspot.com/2014/03/collection-initializer.html">Collection Inititalizer</a>
<a href="http://microsoft-csharp-net.blogspot.com/2014/03/print-document-class.html">Print Document Class</a>
</div><br/>
<div class="divh1"> Collection</div><br/>
<div style="text-align: center;">
<script async="async" type="text/javascript">
( function() {
if (window.CHITIKA === undefined) { window.CHITIKA = { 'units' : [] }; };
var unit = {"calltype":"async[2]","publisher":"jayalaxmi0044","width":468,"height":180,"sid":"Chitika Default","color_button":"10404c","color_button_text":"ffffff"};
var placement_id = window.CHITIKA.units.length;
window.CHITIKA.units.push(unit);
document.write('<div id="chitikaAdBlock-' + placement_id + '"></div>');
}());
</script>
<script type="text/javascript" src="//cdn.chitika.net/getads.js" async="async"></script>
</div>
<ul>
<li>The concept of collections is basically developed from Arrays.</li>
<li>Already you know that, arrays are multiple value containers of fixed type.</li>
<li>In order to hold different types of values on the same array, you require collections.</li>
<li>Another advantage of collections is those are dynamic sizable. In other words, the array is of fixed size and the collection is of dynamic size.</li>
<li>Finally, if you don‘t know how many values are to be stored in the array at the time of its declaration, you require to use collections; (or) if you want to store different type of values in the same array, at that case also, you require to use collections.</li>
<li>.NET offers some pre-defined classes for maintenance of collections.</li>
</ul>
<div class="divh1"> Collection Classes:</div>
<h2 style="text-align: left;">
<span style="font-weight: normal;"><span style="color: blue;"><i>List:</i></span></span></h2>
<div>
<ol style="text-align: left;">
<li>Contains n no. of values of same type. It‘s a generic class.</li>
<li>This is member of ―System.Collections.Generic” namespace.</li>
</ol>
</div>
<h3 style="text-align: left;">
<span style="font-weight: normal;"><span style="color: blue;">ArrayList:</span></span></h3>
<ol style="text-align: left;">
<li>Contains n no. of values of different types.</li>
<li>This is member of System.Collections namespace</li>
</ol>
<div class="divh1"> Implementation of “List” class:</div>
<div>
<ul style="text-align: left;">
<li><b>Import namespace:</b></li>
</ul>
</div>
<div>
<span style="color: red;"> using System.Collections.Generic;</span></div>
<div>
<ul style="text-align: left;">
<li>Create instance:</li>
</ul>
</div>
<div>
<span style="color: red;"> List<data type> obj = new List<data type>();</span></div>
<div>
<ul style="text-align: left;">
<li>Add values:</li>
</ul>
</div>
<div>
<span style="color: red;"> obj.Add(value);</span></div>
<div>
<ul style="text-align: left;">
<li>Get the currently existing no. of values in the collection:</li>
</ul>
</div>
<div>
<span style="color: red;"> obj.Count</span></div>
<div>
<ul style="text-align: left;">
<li>Get the individual element in the collection:</li>
</ul>
</div>
<div class="divh1"> Implementation of “ArrayList” class:</div>
<div>
<ul style="text-align: left;">
<li>Import namespace:</li>
</ul>
</div>
<div>
<span style="color: red;"> using System.Collections;</span></div>
<div>
<ul style="text-align: left;">
<li>Create instance:</li>
</ul>
</div>
<div>
<span style="color: red;"> ArrayList obj = new ArayList();</span></div>
<div>
<ul style="text-align: left;">
<li>Add values:</li>
</ul>
</div>
<div>
<span style="color: red;"> obj.Add(value);</span></div>
<div>
<ul style="text-align: left;">
<li>Get the currently existing no. of values in the collection:</li>
</ul>
</div>
<div>
<span style="color: red;"> obj.Count</span></div>
<div>
<ul style="text-align: left;">
<li>Get the individual element in the collection:</li>
</ul>
</div>
<div>
<span style="color: red;"> obj[index];</span></div>
<div class="divh1"> Program of List Class </div>
<pre class="brush:csharp;">
using System.Collections.Generic;
namespace ListClass
{
class Program
{
static void Main(string[] args)
{
List<string> MyMessages = new List<string>();
MyMessages.Add("Good Morning");
MyMessages.Add("Good Afternoon");
MyMessages.Add("Good Evening");
MyMessages.Add("Good Night");
//MyMessages.Add(10); //error
Console.WriteLine(MyMessages.Count + " messages found.\n");
foreach (string s in MyMessages)
{
Console.WriteLine(s);
}
Console.Read();
}
}
}
</pre>
<div class="divh1">PROGRAM OF ARRAYLIST CLASS </div>
<pre class="brush:csharp;">
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections;
namespace ArrayListClass
{
class Program
{
static void Main(string[] args)
{
ArrayList al = new ArrayList();
al.Add("Hai");
al.Add("How r u");
al.Add(1000);
al.Add(true);
al.Add(DateTime.Now);
Console.WriteLine(al.Count + " values found.\n");
for (int i = 0; i < al.Count; i++)
Console.WriteLine(al[i]);
Console.Read();
}
}
}
</pre>
<div style="float:right;">
<a href="http://microsoft-csharp-net.blogspot.in/2014/03/collections.html">Collection</a>
<a href="http://microsoft-csharp-net.blogspot.com/2014/03/collection-initializer.html">Collection Inititalizer</a>
<a href="http://microsoft-csharp-net.blogspot.com/2014/03/print-document-class.html">Print Document Class</a>
</div>
<div align="center">
<script async="async" type="text/javascript">
( function() {
if (window.CHITIKA === undefined) { window.CHITIKA = { 'units' : [] }; };
var unit = {"calltype":"async[2]","publisher":"jayalaxmi0044","width":550,"height":250,"sid":"Chitika Default","color_button":"10404c","color_button_text":"ffffff"};
var placement_id = window.CHITIKA.units.length;
window.CHITIKA.units.push(unit);
document.write('<div id="chitikaAdBlock-' + placement_id + '"></div>');
}());
</script>
<script type="text/javascript" src="//cdn.chitika.net/getads.js" async="async"></script>
</div>
</div>fdfsdfhttp://www.blogger.com/profile/08780252268386268059noreply@blogger.com0