tag:blogger.com,1999:blog-71299297783416487502024-03-13T08:23:30.296+05:30.NET FundamentalsDhruval Shahhttp://www.blogger.com/profile/10913767864566134668noreply@blogger.comBlogger90125tag:blogger.com,1999:blog-7129929778341648750.post-41897374406033374152016-04-12T08:12:00.000+05:302016-04-12T08:12:16.447+05:30Different ways to use TASK in .NET C#<div dir="ltr" style="text-align: left;" trbidi="on">
<!--[if gte mso 9]><xml>
<o:OfficeDocumentSettings>
<o:AllowPNG/>
</o:OfficeDocumentSettings>
</xml><![endif]-->
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="background: white; color: green; font-family: Consolas; font-size: 9.5pt; mso-bidi-font-family: Consolas; mso-highlight: white;"><span style="mso-spacerun: yes;"></span><span style="color: black;">New threads can be started using the Task Programming Library in .NET in
– at last – 5 different ways.</span></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<br /></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="background: white; color: green; font-family: Consolas; font-size: 9.5pt; mso-bidi-font-family: Consolas; mso-highlight: white;"><span style="mso-spacerun: yes;"></span>You’ll first need to add the following using statement:</span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="background: white; color: green; font-family: Consolas; font-size: 9.5pt; mso-bidi-font-family: Consolas; mso-highlight: white;"></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="background: white; color: green; font-family: Consolas; font-size: 9.5pt; mso-bidi-font-family: Consolas; mso-highlight: white;"><!--[if gte mso 9]><xml>
<o:OfficeDocumentSettings>
<o:AllowPNG/>
</o:OfficeDocumentSettings>
</xml><![endif]--><!--[if gte mso 9]><xml>
<w:WordDocument>
<w:View>Normal</w:View>
<w:Zoom>0</w:Zoom>
<w:TrackMoves/>
<w:TrackFormatting/>
<w:PunctuationKerning/>
<w:ValidateAgainstSchemas/>
<w:SaveIfXMLInvalid>false</w:SaveIfXMLInvalid>
<w:IgnoreMixedContent>false</w:IgnoreMixedContent>
<w:AlwaysShowPlaceholderText>false</w:AlwaysShowPlaceholderText>
<w:DoNotPromoteQF/>
<w:LidThemeOther>EN-IN</w:LidThemeOther>
<w:LidThemeAsian>X-NONE</w:LidThemeAsian>
<w:LidThemeComplexScript>X-NONE</w:LidThemeComplexScript>
<w:Compatibility>
<w:BreakWrappedTables/>
<w:SnapToGridInCell/>
<w:WrapTextWithPunct/>
<w:UseAsianBreakRules/>
<w:DontGrowAutofit/>
<w:SplitPgBreakAndParaMark/>
<w:EnableOpenTypeKerning/>
<w:DontFlipMirrorIndents/>
<w:OverrideTableStyleHps/>
</w:Compatibility>
<m:mathPr>
<m:mathFont m:val="Cambria Math"/>
<m:brkBin m:val="before"/>
<m:brkBinSub m:val="--"/>
<m:smallFrac m:val="off"/>
<m:dispDef/>
<m:lMargin m:val="0"/>
<m:rMargin m:val="0"/>
<m:defJc m:val="centerGroup"/>
<m:wrapIndent m:val="1440"/>
<m:intLim m:val="subSup"/>
<m:naryLim m:val="undOvr"/>
</m:mathPr></w:WordDocument>
</xml><![endif]--><!--[if gte mso 9]><xml>
<w:LatentStyles DefLockedState="false" DefUnhideWhenUsed="false"
DefSemiHidden="false" DefQFormat="false" DefPriority="99"
LatentStyleCount="372">
<w:LsdException Locked="false" Priority="0" QFormat="true" Name="Normal"/>
<w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 1"/>
<w:LsdException Locked="false" Priority="9" SemiHidden="true"
UnhideWhenUsed="true" QFormat="true" Name="heading 2"/>
<w:LsdException Locked="false" Priority="9" SemiHidden="true"
UnhideWhenUsed="true" QFormat="true" Name="heading 3"/>
<w:LsdException Locked="false" Priority="9" SemiHidden="true"
UnhideWhenUsed="true" QFormat="true" Name="heading 4"/>
<w:LsdException Locked="false" Priority="9" SemiHidden="true"
UnhideWhenUsed="true" QFormat="true" Name="heading 5"/>
<w:LsdException Locked="false" Priority="9" SemiHidden="true"
UnhideWhenUsed="true" QFormat="true" Name="heading 6"/>
<w:LsdException Locked="false" Priority="9" SemiHidden="true"
UnhideWhenUsed="true" QFormat="true" Name="heading 7"/>
<w:LsdException Locked="false" Priority="9" SemiHidden="true"
UnhideWhenUsed="true" QFormat="true" Name="heading 8"/>
<w:LsdException Locked="false" Priority="9" SemiHidden="true"
UnhideWhenUsed="true" QFormat="true" Name="heading 9"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="index 1"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="index 2"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="index 3"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="index 4"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="index 5"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="index 6"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="index 7"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="index 8"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="index 9"/>
<w:LsdException Locked="false" Priority="39" SemiHidden="true"
UnhideWhenUsed="true" Name="toc 1"/>
<w:LsdException Locked="false" Priority="39" SemiHidden="true"
UnhideWhenUsed="true" Name="toc 2"/>
<w:LsdException Locked="false" Priority="39" SemiHidden="true"
UnhideWhenUsed="true" Name="toc 3"/>
<w:LsdException Locked="false" Priority="39" SemiHidden="true"
UnhideWhenUsed="true" Name="toc 4"/>
<w:LsdException Locked="false" Priority="39" SemiHidden="true"
UnhideWhenUsed="true" Name="toc 5"/>
<w:LsdException Locked="false" Priority="39" SemiHidden="true"
UnhideWhenUsed="true" Name="toc 6"/>
<w:LsdException Locked="false" Priority="39" SemiHidden="true"
UnhideWhenUsed="true" Name="toc 7"/>
<w:LsdException Locked="false" Priority="39" SemiHidden="true"
UnhideWhenUsed="true" Name="toc 8"/>
<w:LsdException Locked="false" Priority="39" SemiHidden="true"
UnhideWhenUsed="true" Name="toc 9"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="Normal Indent"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="footnote text"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="annotation text"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="header"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="footer"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="index heading"/>
<w:LsdException Locked="false" Priority="35" SemiHidden="true"
UnhideWhenUsed="true" QFormat="true" Name="caption"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="table of figures"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="envelope address"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="envelope return"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="footnote reference"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="annotation reference"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="line number"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="page number"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="endnote reference"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="endnote text"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="table of authorities"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="macro"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="toa heading"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="List"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="List Bullet"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="List Number"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="List 2"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="List 3"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="List 4"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="List 5"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="List Bullet 2"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="List Bullet 3"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="List Bullet 4"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="List Bullet 5"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="List Number 2"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="List Number 3"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="List Number 4"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="List Number 5"/>
<w:LsdException Locked="false" Priority="10" QFormat="true" Name="Title"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="Closing"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="Signature"/>
<w:LsdException Locked="false" Priority="1" SemiHidden="true"
UnhideWhenUsed="true" Name="Default Paragraph Font"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="Body Text"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="Body Text Indent"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="List Continue"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="List Continue 2"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="List Continue 3"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="List Continue 4"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="List Continue 5"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="Message Header"/>
<w:LsdException Locked="false" Priority="11" QFormat="true" Name="Subtitle"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="Salutation"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="Date"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="Body Text First Indent"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="Body Text First Indent 2"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="Note Heading"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="Body Text 2"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="Body Text 3"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="Body Text Indent 2"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="Body Text Indent 3"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="Block Text"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="Hyperlink"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="FollowedHyperlink"/>
<w:LsdException Locked="false" Priority="22" QFormat="true" Name="Strong"/>
<w:LsdException Locked="false" Priority="20" QFormat="true" Name="Emphasis"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="Document Map"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="Plain Text"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="E-mail Signature"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="HTML Top of Form"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="HTML Bottom of Form"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="Normal (Web)"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="HTML Acronym"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="HTML Address"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="HTML Cite"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="HTML Code"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="HTML Definition"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="HTML Keyboard"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="HTML Preformatted"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="HTML Sample"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="HTML Typewriter"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="HTML Variable"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="Normal Table"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="annotation subject"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="No List"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="Outline List 1"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="Outline List 2"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="Outline List 3"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="Table Simple 1"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="Table Simple 2"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="Table Simple 3"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="Table Classic 1"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="Table Classic 2"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="Table Classic 3"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="Table Classic 4"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="Table Colorful 1"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="Table Colorful 2"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="Table Colorful 3"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="Table Columns 1"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="Table Columns 2"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="Table Columns 3"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="Table Columns 4"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="Table Columns 5"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="Table Grid 1"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="Table Grid 2"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="Table Grid 3"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="Table Grid 4"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="Table Grid 5"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="Table Grid 6"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="Table Grid 7"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="Table Grid 8"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="Table List 1"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="Table List 2"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="Table List 3"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="Table List 4"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="Table List 5"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="Table List 6"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="Table List 7"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="Table List 8"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="Table 3D effects 1"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="Table 3D effects 2"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="Table 3D effects 3"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="Table Contemporary"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="Table Elegant"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="Table Professional"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="Table Subtle 1"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="Table Subtle 2"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="Table Web 1"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="Table Web 2"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="Table Web 3"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="Balloon Text"/>
<w:LsdException Locked="false" Priority="39" Name="Table Grid"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="Table Theme"/>
<w:LsdException Locked="false" SemiHidden="true" Name="Placeholder Text"/>
<w:LsdException Locked="false" Priority="1" QFormat="true" Name="No Spacing"/>
<w:LsdException Locked="false" Priority="60" Name="Light Shading"/>
<w:LsdException Locked="false" Priority="61" Name="Light List"/>
<w:LsdException Locked="false" Priority="62" Name="Light Grid"/>
<w:LsdException Locked="false" Priority="63" Name="Medium Shading 1"/>
<w:LsdException Locked="false" Priority="64" Name="Medium Shading 2"/>
<w:LsdException Locked="false" Priority="65" Name="Medium List 1"/>
<w:LsdException Locked="false" Priority="66" Name="Medium List 2"/>
<w:LsdException Locked="false" Priority="67" Name="Medium Grid 1"/>
<w:LsdException Locked="false" Priority="68" Name="Medium Grid 2"/>
<w:LsdException Locked="false" Priority="69" Name="Medium Grid 3"/>
<w:LsdException Locked="false" Priority="70" Name="Dark List"/>
<w:LsdException Locked="false" Priority="71" Name="Colorful Shading"/>
<w:LsdException Locked="false" Priority="72" Name="Colorful List"/>
<w:LsdException Locked="false" Priority="73" Name="Colorful Grid"/>
<w:LsdException Locked="false" Priority="60" Name="Light Shading Accent 1"/>
<w:LsdException Locked="false" Priority="61" Name="Light List Accent 1"/>
<w:LsdException Locked="false" Priority="62" Name="Light Grid Accent 1"/>
<w:LsdException Locked="false" Priority="63" Name="Medium Shading 1 Accent 1"/>
<w:LsdException Locked="false" Priority="64" Name="Medium Shading 2 Accent 1"/>
<w:LsdException Locked="false" Priority="65" Name="Medium List 1 Accent 1"/>
<w:LsdException Locked="false" SemiHidden="true" Name="Revision"/>
<w:LsdException Locked="false" Priority="34" QFormat="true"
Name="List Paragraph"/>
<w:LsdException Locked="false" Priority="29" QFormat="true" Name="Quote"/>
<w:LsdException Locked="false" Priority="30" QFormat="true"
Name="Intense Quote"/>
<w:LsdException Locked="false" Priority="66" Name="Medium List 2 Accent 1"/>
<w:LsdException Locked="false" Priority="67" Name="Medium Grid 1 Accent 1"/>
<w:LsdException Locked="false" Priority="68" Name="Medium Grid 2 Accent 1"/>
<w:LsdException Locked="false" Priority="69" Name="Medium Grid 3 Accent 1"/>
<w:LsdException Locked="false" Priority="70" Name="Dark List Accent 1"/>
<w:LsdException Locked="false" Priority="71" Name="Colorful Shading Accent 1"/>
<w:LsdException Locked="false" Priority="72" Name="Colorful List Accent 1"/>
<w:LsdException Locked="false" Priority="73" Name="Colorful Grid Accent 1"/>
<w:LsdException Locked="false" Priority="60" Name="Light Shading Accent 2"/>
<w:LsdException Locked="false" Priority="61" Name="Light List Accent 2"/>
<w:LsdException Locked="false" Priority="62" Name="Light Grid Accent 2"/>
<w:LsdException Locked="false" Priority="63" Name="Medium Shading 1 Accent 2"/>
<w:LsdException Locked="false" Priority="64" Name="Medium Shading 2 Accent 2"/>
<w:LsdException Locked="false" Priority="65" Name="Medium List 1 Accent 2"/>
<w:LsdException Locked="false" Priority="66" Name="Medium List 2 Accent 2"/>
<w:LsdException Locked="false" Priority="67" Name="Medium Grid 1 Accent 2"/>
<w:LsdException Locked="false" Priority="68" Name="Medium Grid 2 Accent 2"/>
<w:LsdException Locked="false" Priority="69" Name="Medium Grid 3 Accent 2"/>
<w:LsdException Locked="false" Priority="70" Name="Dark List Accent 2"/>
<w:LsdException Locked="false" Priority="71" Name="Colorful Shading Accent 2"/>
<w:LsdException Locked="false" Priority="72" Name="Colorful List Accent 2"/>
<w:LsdException Locked="false" Priority="73" Name="Colorful Grid Accent 2"/>
<w:LsdException Locked="false" Priority="60" Name="Light Shading Accent 3"/>
<w:LsdException Locked="false" Priority="61" Name="Light List Accent 3"/>
<w:LsdException Locked="false" Priority="62" Name="Light Grid Accent 3"/>
<w:LsdException Locked="false" Priority="63" Name="Medium Shading 1 Accent 3"/>
<w:LsdException Locked="false" Priority="64" Name="Medium Shading 2 Accent 3"/>
<w:LsdException Locked="false" Priority="65" Name="Medium List 1 Accent 3"/>
<w:LsdException Locked="false" Priority="66" Name="Medium List 2 Accent 3"/>
<w:LsdException Locked="false" Priority="67" Name="Medium Grid 1 Accent 3"/>
<w:LsdException Locked="false" Priority="68" Name="Medium Grid 2 Accent 3"/>
<w:LsdException Locked="false" Priority="69" Name="Medium Grid 3 Accent 3"/>
<w:LsdException Locked="false" Priority="70" Name="Dark List Accent 3"/>
<w:LsdException Locked="false" Priority="71" Name="Colorful Shading Accent 3"/>
<w:LsdException Locked="false" Priority="72" Name="Colorful List Accent 3"/>
<w:LsdException Locked="false" Priority="73" Name="Colorful Grid Accent 3"/>
<w:LsdException Locked="false" Priority="60" Name="Light Shading Accent 4"/>
<w:LsdException Locked="false" Priority="61" Name="Light List Accent 4"/>
<w:LsdException Locked="false" Priority="62" Name="Light Grid Accent 4"/>
<w:LsdException Locked="false" Priority="63" Name="Medium Shading 1 Accent 4"/>
<w:LsdException Locked="false" Priority="64" Name="Medium Shading 2 Accent 4"/>
<w:LsdException Locked="false" Priority="65" Name="Medium List 1 Accent 4"/>
<w:LsdException Locked="false" Priority="66" Name="Medium List 2 Accent 4"/>
<w:LsdException Locked="false" Priority="67" Name="Medium Grid 1 Accent 4"/>
<w:LsdException Locked="false" Priority="68" Name="Medium Grid 2 Accent 4"/>
<w:LsdException Locked="false" Priority="69" Name="Medium Grid 3 Accent 4"/>
<w:LsdException Locked="false" Priority="70" Name="Dark List Accent 4"/>
<w:LsdException Locked="false" Priority="71" Name="Colorful Shading Accent 4"/>
<w:LsdException Locked="false" Priority="72" Name="Colorful List Accent 4"/>
<w:LsdException Locked="false" Priority="73" Name="Colorful Grid Accent 4"/>
<w:LsdException Locked="false" Priority="60" Name="Light Shading Accent 5"/>
<w:LsdException Locked="false" Priority="61" Name="Light List Accent 5"/>
<w:LsdException Locked="false" Priority="62" Name="Light Grid Accent 5"/>
<w:LsdException Locked="false" Priority="63" Name="Medium Shading 1 Accent 5"/>
<w:LsdException Locked="false" Priority="64" Name="Medium Shading 2 Accent 5"/>
<w:LsdException Locked="false" Priority="65" Name="Medium List 1 Accent 5"/>
<w:LsdException Locked="false" Priority="66" Name="Medium List 2 Accent 5"/>
<w:LsdException Locked="false" Priority="67" Name="Medium Grid 1 Accent 5"/>
<w:LsdException Locked="false" Priority="68" Name="Medium Grid 2 Accent 5"/>
<w:LsdException Locked="false" Priority="69" Name="Medium Grid 3 Accent 5"/>
<w:LsdException Locked="false" Priority="70" Name="Dark List Accent 5"/>
<w:LsdException Locked="false" Priority="71" Name="Colorful Shading Accent 5"/>
<w:LsdException Locked="false" Priority="72" Name="Colorful List Accent 5"/>
<w:LsdException Locked="false" Priority="73" Name="Colorful Grid Accent 5"/>
<w:LsdException Locked="false" Priority="60" Name="Light Shading Accent 6"/>
<w:LsdException Locked="false" Priority="61" Name="Light List Accent 6"/>
<w:LsdException Locked="false" Priority="62" Name="Light Grid Accent 6"/>
<w:LsdException Locked="false" Priority="63" Name="Medium Shading 1 Accent 6"/>
<w:LsdException Locked="false" Priority="64" Name="Medium Shading 2 Accent 6"/>
<w:LsdException Locked="false" Priority="65" Name="Medium List 1 Accent 6"/>
<w:LsdException Locked="false" Priority="66" Name="Medium List 2 Accent 6"/>
<w:LsdException Locked="false" Priority="67" Name="Medium Grid 1 Accent 6"/>
<w:LsdException Locked="false" Priority="68" Name="Medium Grid 2 Accent 6"/>
<w:LsdException Locked="false" Priority="69" Name="Medium Grid 3 Accent 6"/>
<w:LsdException Locked="false" Priority="70" Name="Dark List Accent 6"/>
<w:LsdException Locked="false" Priority="71" Name="Colorful Shading Accent 6"/>
<w:LsdException Locked="false" Priority="72" Name="Colorful List Accent 6"/>
<w:LsdException Locked="false" Priority="73" Name="Colorful Grid Accent 6"/>
<w:LsdException Locked="false" Priority="19" QFormat="true"
Name="Subtle Emphasis"/>
<w:LsdException Locked="false" Priority="21" QFormat="true"
Name="Intense Emphasis"/>
<w:LsdException Locked="false" Priority="31" QFormat="true"
Name="Subtle Reference"/>
<w:LsdException Locked="false" Priority="32" QFormat="true"
Name="Intense Reference"/>
<w:LsdException Locked="false" Priority="33" QFormat="true" Name="Book Title"/>
<w:LsdException Locked="false" Priority="37" SemiHidden="true"
UnhideWhenUsed="true" Name="Bibliography"/>
<w:LsdException Locked="false" Priority="39" SemiHidden="true"
UnhideWhenUsed="true" QFormat="true" Name="TOC Heading"/>
<w:LsdException Locked="false" Priority="41" Name="Plain Table 1"/>
<w:LsdException Locked="false" Priority="42" Name="Plain Table 2"/>
<w:LsdException Locked="false" Priority="43" Name="Plain Table 3"/>
<w:LsdException Locked="false" Priority="44" Name="Plain Table 4"/>
<w:LsdException Locked="false" Priority="45" Name="Plain Table 5"/>
<w:LsdException Locked="false" Priority="40" Name="Grid Table Light"/>
<w:LsdException Locked="false" Priority="46" Name="Grid Table 1 Light"/>
<w:LsdException Locked="false" Priority="47" Name="Grid Table 2"/>
<w:LsdException Locked="false" Priority="48" Name="Grid Table 3"/>
<w:LsdException Locked="false" Priority="49" Name="Grid Table 4"/>
<w:LsdException Locked="false" Priority="50" Name="Grid Table 5 Dark"/>
<w:LsdException Locked="false" Priority="51" Name="Grid Table 6 Colorful"/>
<w:LsdException Locked="false" Priority="52" Name="Grid Table 7 Colorful"/>
<w:LsdException Locked="false" Priority="46"
Name="Grid Table 1 Light Accent 1"/>
<w:LsdException Locked="false" Priority="47" Name="Grid Table 2 Accent 1"/>
<w:LsdException Locked="false" Priority="48" Name="Grid Table 3 Accent 1"/>
<w:LsdException Locked="false" Priority="49" Name="Grid Table 4 Accent 1"/>
<w:LsdException Locked="false" Priority="50" Name="Grid Table 5 Dark Accent 1"/>
<w:LsdException Locked="false" Priority="51"
Name="Grid Table 6 Colorful Accent 1"/>
<w:LsdException Locked="false" Priority="52"
Name="Grid Table 7 Colorful Accent 1"/>
<w:LsdException Locked="false" Priority="46"
Name="Grid Table 1 Light Accent 2"/>
<w:LsdException Locked="false" Priority="47" Name="Grid Table 2 Accent 2"/>
<w:LsdException Locked="false" Priority="48" Name="Grid Table 3 Accent 2"/>
<w:LsdException Locked="false" Priority="49" Name="Grid Table 4 Accent 2"/>
<w:LsdException Locked="false" Priority="50" Name="Grid Table 5 Dark Accent 2"/>
<w:LsdException Locked="false" Priority="51"
Name="Grid Table 6 Colorful Accent 2"/>
<w:LsdException Locked="false" Priority="52"
Name="Grid Table 7 Colorful Accent 2"/>
<w:LsdException Locked="false" Priority="46"
Name="Grid Table 1 Light Accent 3"/>
<w:LsdException Locked="false" Priority="47" Name="Grid Table 2 Accent 3"/>
<w:LsdException Locked="false" Priority="48" Name="Grid Table 3 Accent 3"/>
<w:LsdException Locked="false" Priority="49" Name="Grid Table 4 Accent 3"/>
<w:LsdException Locked="false" Priority="50" Name="Grid Table 5 Dark Accent 3"/>
<w:LsdException Locked="false" Priority="51"
Name="Grid Table 6 Colorful Accent 3"/>
<w:LsdException Locked="false" Priority="52"
Name="Grid Table 7 Colorful Accent 3"/>
<w:LsdException Locked="false" Priority="46"
Name="Grid Table 1 Light Accent 4"/>
<w:LsdException Locked="false" Priority="47" Name="Grid Table 2 Accent 4"/>
<w:LsdException Locked="false" Priority="48" Name="Grid Table 3 Accent 4"/>
<w:LsdException Locked="false" Priority="49" Name="Grid Table 4 Accent 4"/>
<w:LsdException Locked="false" Priority="50" Name="Grid Table 5 Dark Accent 4"/>
<w:LsdException Locked="false" Priority="51"
Name="Grid Table 6 Colorful Accent 4"/>
<w:LsdException Locked="false" Priority="52"
Name="Grid Table 7 Colorful Accent 4"/>
<w:LsdException Locked="false" Priority="46"
Name="Grid Table 1 Light Accent 5"/>
<w:LsdException Locked="false" Priority="47" Name="Grid Table 2 Accent 5"/>
<w:LsdException Locked="false" Priority="48" Name="Grid Table 3 Accent 5"/>
<w:LsdException Locked="false" Priority="49" Name="Grid Table 4 Accent 5"/>
<w:LsdException Locked="false" Priority="50" Name="Grid Table 5 Dark Accent 5"/>
<w:LsdException Locked="false" Priority="51"
Name="Grid Table 6 Colorful Accent 5"/>
<w:LsdException Locked="false" Priority="52"
Name="Grid Table 7 Colorful Accent 5"/>
<w:LsdException Locked="false" Priority="46"
Name="Grid Table 1 Light Accent 6"/>
<w:LsdException Locked="false" Priority="47" Name="Grid Table 2 Accent 6"/>
<w:LsdException Locked="false" Priority="48" Name="Grid Table 3 Accent 6"/>
<w:LsdException Locked="false" Priority="49" Name="Grid Table 4 Accent 6"/>
<w:LsdException Locked="false" Priority="50" Name="Grid Table 5 Dark Accent 6"/>
<w:LsdException Locked="false" Priority="51"
Name="Grid Table 6 Colorful Accent 6"/>
<w:LsdException Locked="false" Priority="52"
Name="Grid Table 7 Colorful Accent 6"/>
<w:LsdException Locked="false" Priority="46" Name="List Table 1 Light"/>
<w:LsdException Locked="false" Priority="47" Name="List Table 2"/>
<w:LsdException Locked="false" Priority="48" Name="List Table 3"/>
<w:LsdException Locked="false" Priority="49" Name="List Table 4"/>
<w:LsdException Locked="false" Priority="50" Name="List Table 5 Dark"/>
<w:LsdException Locked="false" Priority="51" Name="List Table 6 Colorful"/>
<w:LsdException Locked="false" Priority="52" Name="List Table 7 Colorful"/>
<w:LsdException Locked="false" Priority="46"
Name="List Table 1 Light Accent 1"/>
<w:LsdException Locked="false" Priority="47" Name="List Table 2 Accent 1"/>
<w:LsdException Locked="false" Priority="48" Name="List Table 3 Accent 1"/>
<w:LsdException Locked="false" Priority="49" Name="List Table 4 Accent 1"/>
<w:LsdException Locked="false" Priority="50" Name="List Table 5 Dark Accent 1"/>
<w:LsdException Locked="false" Priority="51"
Name="List Table 6 Colorful Accent 1"/>
<w:LsdException Locked="false" Priority="52"
Name="List Table 7 Colorful Accent 1"/>
<w:LsdException Locked="false" Priority="46"
Name="List Table 1 Light Accent 2"/>
<w:LsdException Locked="false" Priority="47" Name="List Table 2 Accent 2"/>
<w:LsdException Locked="false" Priority="48" Name="List Table 3 Accent 2"/>
<w:LsdException Locked="false" Priority="49" Name="List Table 4 Accent 2"/>
<w:LsdException Locked="false" Priority="50" Name="List Table 5 Dark Accent 2"/>
<w:LsdException Locked="false" Priority="51"
Name="List Table 6 Colorful Accent 2"/>
<w:LsdException Locked="false" Priority="52"
Name="List Table 7 Colorful Accent 2"/>
<w:LsdException Locked="false" Priority="46"
Name="List Table 1 Light Accent 3"/>
<w:LsdException Locked="false" Priority="47" Name="List Table 2 Accent 3"/>
<w:LsdException Locked="false" Priority="48" Name="List Table 3 Accent 3"/>
<w:LsdException Locked="false" Priority="49" Name="List Table 4 Accent 3"/>
<w:LsdException Locked="false" Priority="50" Name="List Table 5 Dark Accent 3"/>
<w:LsdException Locked="false" Priority="51"
Name="List Table 6 Colorful Accent 3"/>
<w:LsdException Locked="false" Priority="52"
Name="List Table 7 Colorful Accent 3"/>
<w:LsdException Locked="false" Priority="46"
Name="List Table 1 Light Accent 4"/>
<w:LsdException Locked="false" Priority="47" Name="List Table 2 Accent 4"/>
<w:LsdException Locked="false" Priority="48" Name="List Table 3 Accent 4"/>
<w:LsdException Locked="false" Priority="49" Name="List Table 4 Accent 4"/>
<w:LsdException Locked="false" Priority="50" Name="List Table 5 Dark Accent 4"/>
<w:LsdException Locked="false" Priority="51"
Name="List Table 6 Colorful Accent 4"/>
<w:LsdException Locked="false" Priority="52"
Name="List Table 7 Colorful Accent 4"/>
<w:LsdException Locked="false" Priority="46"
Name="List Table 1 Light Accent 5"/>
<w:LsdException Locked="false" Priority="47" Name="List Table 2 Accent 5"/>
<w:LsdException Locked="false" Priority="48" Name="List Table 3 Accent 5"/>
<w:LsdException Locked="false" Priority="49" Name="List Table 4 Accent 5"/>
<w:LsdException Locked="false" Priority="50" Name="List Table 5 Dark Accent 5"/>
<w:LsdException Locked="false" Priority="51"
Name="List Table 6 Colorful Accent 5"/>
<w:LsdException Locked="false" Priority="52"
Name="List Table 7 Colorful Accent 5"/>
<w:LsdException Locked="false" Priority="46"
Name="List Table 1 Light Accent 6"/>
<w:LsdException Locked="false" Priority="47" Name="List Table 2 Accent 6"/>
<w:LsdException Locked="false" Priority="48" Name="List Table 3 Accent 6"/>
<w:LsdException Locked="false" Priority="49" Name="List Table 4 Accent 6"/>
<w:LsdException Locked="false" Priority="50" Name="List Table 5 Dark Accent 6"/>
<w:LsdException Locked="false" Priority="51"
Name="List Table 6 Colorful Accent 6"/>
<w:LsdException Locked="false" Priority="52"
Name="List Table 7 Colorful Accent 6"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="Mention"/>
</w:LatentStyles>
</xml><![endif]--><!--[if gte mso 10]>
<style>
/* Style Definitions */
table.MsoNormalTable
{mso-style-name:"Table Normal";
mso-tstyle-rowband-size:0;
mso-tstyle-colband-size:0;
mso-style-noshow:yes;
mso-style-priority:99;
mso-style-parent:"";
mso-padding-alt:0cm 5.4pt 0cm 5.4pt;
mso-para-margin-top:0cm;
mso-para-margin-right:0cm;
mso-para-margin-bottom:10.0pt;
mso-para-margin-left:0cm;
line-height:115%;
mso-pagination:widow-orphan;
font-size:11.0pt;
font-family:"Calibri",sans-serif;
mso-ascii-font-family:Calibri;
mso-ascii-theme-font:minor-latin;
mso-hansi-font-family:Calibri;
mso-hansi-theme-font:minor-latin;
mso-fareast-language:EN-US;}
</style>
<![endif]-->
</span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<br /></div>
<div class="MsoNormal">
<span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; line-height: 115%; mso-bidi-font-family: Consolas; mso-highlight: white;">using</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; line-height: 115%; mso-bidi-font-family: Consolas; mso-highlight: white;"> System.Threading.Tasks;</span></div>
<span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-bidi-font-family: Consolas; mso-highlight: white;"></span><br />
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<u><b><span style="background: white; color: green; font-family: Consolas; font-size: 9.5pt; mso-bidi-font-family: Consolas; mso-highlight: white;"><span style="mso-spacerun: yes;"></span>The most direct way</span></b></u><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-bidi-font-family: Consolas; mso-highlight: white;"></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<br /></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="background: white; color: #2b91af; font-family: Consolas; font-size: 9.5pt; mso-bidi-font-family: Consolas; mso-highlight: white;">Task</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-bidi-font-family: Consolas; mso-highlight: white;">.Factory.StartNew(() => {</span><span style="background: white; color: #2b91af; font-family: Consolas; font-size: 9.5pt; mso-bidi-font-family: Consolas; mso-highlight: white;">Console</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-bidi-font-family: Consolas; mso-highlight: white;">.WriteLine(</span><span style="background: white; color: #a31515; font-family: Consolas; font-size: 9.5pt; mso-bidi-font-family: Consolas; mso-highlight: white;">"Hello Task library!"</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-bidi-font-family: Consolas; mso-highlight: white;">); });</span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<br /></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<u><b><span style="background: white; color: green; font-family: Consolas; font-size: 9.5pt; mso-bidi-font-family: Consolas; mso-highlight: white;"><span style="mso-spacerun: yes;"></span>Using Action</span></b></u><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-bidi-font-family: Consolas; mso-highlight: white;"></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-bidi-font-family: Consolas; mso-highlight: white;">Task task = </span><span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-bidi-font-family: Consolas; mso-highlight: white;">new</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-bidi-font-family: Consolas; mso-highlight: white;"> Task(</span><span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-bidi-font-family: Consolas; mso-highlight: white;">new</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-bidi-font-family: Consolas; mso-highlight: white;"> Action(PrintMessage));</span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-bidi-font-family: Consolas; mso-highlight: white;">task.Start();</span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<br /></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="background: white; color: green; font-family: Consolas; font-size: 9.5pt; mso-bidi-font-family: Consolas; mso-highlight: white;">where PrintMessage is a method:</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-bidi-font-family: Consolas; mso-highlight: white;"></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<br /></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-bidi-font-family: Consolas; mso-highlight: white;">private</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-bidi-font-family: Consolas; mso-highlight: white;"> </span><span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-bidi-font-family: Consolas; mso-highlight: white;">void</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-bidi-font-family: Consolas; mso-highlight: white;"> PrintMessage()</span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-bidi-font-family: Consolas; mso-highlight: white;">{</span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-bidi-font-family: Consolas; mso-highlight: white;"><span style="mso-spacerun: yes;">
</span>Console.WriteLine(</span><span style="background: white; color: #a31515; font-family: Consolas; font-size: 9.5pt; mso-bidi-font-family: Consolas; mso-highlight: white;">"Hello Task library!"</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-bidi-font-family: Consolas; mso-highlight: white;">);</span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-bidi-font-family: Consolas; mso-highlight: white;">}</span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<br /></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<br /></div>
<u><b>
</b></u><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<u><b><span style="background: white; color: green; font-family: Consolas; font-size: 9.5pt; mso-bidi-font-family: Consolas; mso-highlight: white;">Using a delegate</span></b></u><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-bidi-font-family: Consolas; mso-highlight: white;"></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-bidi-font-family: Consolas; mso-highlight: white;">Task task = </span><span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-bidi-font-family: Consolas; mso-highlight: white;">new</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-bidi-font-family: Consolas; mso-highlight: white;"> Task(</span><span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-bidi-font-family: Consolas; mso-highlight: white;">delegate</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-bidi-font-family: Consolas; mso-highlight: white;"> { PrintMessage(); });</span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-bidi-font-family: Consolas; mso-highlight: white;">task.Start();</span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<br /></div>
<u><b>
</b></u><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<u><b><span style="background: white; color: green; font-family: Consolas; font-size: 9.5pt; mso-bidi-font-family: Consolas; mso-highlight: white;">Lambda and named method</span></b></u><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-bidi-font-family: Consolas; mso-highlight: white;"></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-bidi-font-family: Consolas; mso-highlight: white;">Task task = </span><span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-bidi-font-family: Consolas; mso-highlight: white;">new</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-bidi-font-family: Consolas; mso-highlight: white;"> Task( () =>
PrintMessage() );</span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-bidi-font-family: Consolas; mso-highlight: white;">task.Start();</span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<br /></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<u><b><span style="background: white; color: green; font-family: Consolas; font-size: 9.5pt; mso-bidi-font-family: Consolas; mso-highlight: white;">Lambda and anonymous method</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-bidi-font-family: Consolas; mso-highlight: white;"></span></b></u></div>
<u><b>
</b></u><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-bidi-font-family: Consolas; mso-highlight: white;">Task task = </span><span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-bidi-font-family: Consolas; mso-highlight: white;">new</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-bidi-font-family: Consolas; mso-highlight: white;"> Task( () => {
PrintMessage(); } );</span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-bidi-font-family: Consolas; mso-highlight: white;">task.Start();</span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<br /></div>
<span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-bidi-font-family: Consolas; mso-highlight: white;"><span style="mso-spacerun: yes;"></span></span><u><b><span style="background: white; color: green; font-family: Consolas; font-size: 9.5pt; mso-bidi-font-family: Consolas; mso-highlight: white;">Using Task.Run in
.NET4.5</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-bidi-font-family: Consolas; mso-highlight: white;"></span>
</b></u><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<br /></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-bidi-font-family: Consolas; mso-highlight: white;"><span style="mso-spacerun: yes;"></span></span><span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-bidi-font-family: Consolas; mso-highlight: white;">public</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-bidi-font-family: Consolas; mso-highlight: white;"> async Task DoWork()</span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-bidi-font-family: Consolas; mso-highlight: white;">{</span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-bidi-font-family: Consolas; mso-highlight: white;"><span style="mso-spacerun: yes;">
</span>await Task.Run(() => PrintMessage());</span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-bidi-font-family: Consolas; mso-highlight: white;">}</span></div>
<br />
<u><b><span style="background: white; color: green; font-family: Consolas; font-size: 9.5pt; mso-bidi-font-family: Consolas; mso-highlight: white;">Using
Task.FromResult in .NET4.5 to return a result from a Task</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-bidi-font-family: Consolas; mso-highlight: white;"></span></b></u>
<br />
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<br /></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-bidi-font-family: Consolas; mso-highlight: white;"><span style="mso-spacerun: yes;"></span></span><span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-bidi-font-family: Consolas; mso-highlight: white;">public</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-bidi-font-family: Consolas; mso-highlight: white;"> async Task DoWork()</span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-bidi-font-family: Consolas; mso-highlight: white;">{</span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-bidi-font-family: Consolas; mso-highlight: white;"><span style="mso-spacerun: yes;">
</span></span><span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-bidi-font-family: Consolas; mso-highlight: white;">int</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-bidi-font-family: Consolas; mso-highlight: white;"> res = await
Task.FromResult<</span><span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-bidi-font-family: Consolas; mso-highlight: white;">int</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-bidi-font-family: Consolas; mso-highlight: white;">>(GetSum(4, 5));<span style="mso-spacerun: yes;"> </span></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-bidi-font-family: Consolas; mso-highlight: white;">}</span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<br /></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-bidi-font-family: Consolas; mso-highlight: white;">private</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-bidi-font-family: Consolas; mso-highlight: white;"> </span><span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-bidi-font-family: Consolas; mso-highlight: white;">int</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-bidi-font-family: Consolas; mso-highlight: white;"> GetSum(</span><span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-bidi-font-family: Consolas; mso-highlight: white;">int</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-bidi-font-family: Consolas; mso-highlight: white;"> a, </span><span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-bidi-font-family: Consolas; mso-highlight: white;">int</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-bidi-font-family: Consolas; mso-highlight: white;"> b)</span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-bidi-font-family: Consolas; mso-highlight: white;">{</span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-bidi-font-family: Consolas; mso-highlight: white;"><span style="mso-spacerun: yes;">
</span></span><span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-bidi-font-family: Consolas; mso-highlight: white;">return</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-bidi-font-family: Consolas; mso-highlight: white;"> a + b;</span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-bidi-font-family: Consolas; mso-highlight: white;">}</span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<br /></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-bidi-font-family: Consolas; mso-highlight: white;"><span style="mso-spacerun: yes;"> </span>You cannot start a task that has already completed. If you need to run
the same task you’ll need to initialise it again.</span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<br /></div>
<div class="MsoNormal">
<br /></div>
<!--[if gte mso 9]><xml>
<w:WordDocument>
<w:View>Normal</w:View>
<w:Zoom>0</w:Zoom>
<w:TrackMoves/>
<w:TrackFormatting/>
<w:PunctuationKerning/>
<w:ValidateAgainstSchemas/>
<w:SaveIfXMLInvalid>false</w:SaveIfXMLInvalid>
<w:IgnoreMixedContent>false</w:IgnoreMixedContent>
<w:AlwaysShowPlaceholderText>false</w:AlwaysShowPlaceholderText>
<w:DoNotPromoteQF/>
<w:LidThemeOther>EN-IN</w:LidThemeOther>
<w:LidThemeAsian>X-NONE</w:LidThemeAsian>
<w:LidThemeComplexScript>X-NONE</w:LidThemeComplexScript>
<w:Compatibility>
<w:BreakWrappedTables/>
<w:SnapToGridInCell/>
<w:WrapTextWithPunct/>
<w:UseAsianBreakRules/>
<w:DontGrowAutofit/>
<w:SplitPgBreakAndParaMark/>
<w:EnableOpenTypeKerning/>
<w:DontFlipMirrorIndents/>
<w:OverrideTableStyleHps/>
</w:Compatibility>
<m:mathPr>
<m:mathFont m:val="Cambria Math"/>
<m:brkBin m:val="before"/>
<m:brkBinSub m:val="--"/>
<m:smallFrac m:val="off"/>
<m:dispDef/>
<m:lMargin m:val="0"/>
<m:rMargin m:val="0"/>
<m:defJc m:val="centerGroup"/>
<m:wrapIndent m:val="1440"/>
<m:intLim m:val="subSup"/>
<m:naryLim m:val="undOvr"/>
</m:mathPr></w:WordDocument>
</xml><![endif]--><!--[if gte mso 9]><xml>
<w:LatentStyles DefLockedState="false" DefUnhideWhenUsed="false"
DefSemiHidden="false" DefQFormat="false" DefPriority="99"
LatentStyleCount="372">
<w:LsdException Locked="false" Priority="0" QFormat="true" Name="Normal"/>
<w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 1"/>
<w:LsdException Locked="false" Priority="9" SemiHidden="true"
UnhideWhenUsed="true" QFormat="true" Name="heading 2"/>
<w:LsdException Locked="false" Priority="9" SemiHidden="true"
UnhideWhenUsed="true" QFormat="true" Name="heading 3"/>
<w:LsdException Locked="false" Priority="9" SemiHidden="true"
UnhideWhenUsed="true" QFormat="true" Name="heading 4"/>
<w:LsdException Locked="false" Priority="9" SemiHidden="true"
UnhideWhenUsed="true" QFormat="true" Name="heading 5"/>
<w:LsdException Locked="false" Priority="9" SemiHidden="true"
UnhideWhenUsed="true" QFormat="true" Name="heading 6"/>
<w:LsdException Locked="false" Priority="9" SemiHidden="true"
UnhideWhenUsed="true" QFormat="true" Name="heading 7"/>
<w:LsdException Locked="false" Priority="9" SemiHidden="true"
UnhideWhenUsed="true" QFormat="true" Name="heading 8"/>
<w:LsdException Locked="false" Priority="9" SemiHidden="true"
UnhideWhenUsed="true" QFormat="true" Name="heading 9"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="index 1"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="index 2"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="index 3"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="index 4"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="index 5"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="index 6"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="index 7"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="index 8"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="index 9"/>
<w:LsdException Locked="false" Priority="39" SemiHidden="true"
UnhideWhenUsed="true" Name="toc 1"/>
<w:LsdException Locked="false" Priority="39" SemiHidden="true"
UnhideWhenUsed="true" Name="toc 2"/>
<w:LsdException Locked="false" Priority="39" SemiHidden="true"
UnhideWhenUsed="true" Name="toc 3"/>
<w:LsdException Locked="false" Priority="39" SemiHidden="true"
UnhideWhenUsed="true" Name="toc 4"/>
<w:LsdException Locked="false" Priority="39" SemiHidden="true"
UnhideWhenUsed="true" Name="toc 5"/>
<w:LsdException Locked="false" Priority="39" SemiHidden="true"
UnhideWhenUsed="true" Name="toc 6"/>
<w:LsdException Locked="false" Priority="39" SemiHidden="true"
UnhideWhenUsed="true" Name="toc 7"/>
<w:LsdException Locked="false" Priority="39" SemiHidden="true"
UnhideWhenUsed="true" Name="toc 8"/>
<w:LsdException Locked="false" Priority="39" SemiHidden="true"
UnhideWhenUsed="true" Name="toc 9"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="Normal Indent"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="footnote text"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="annotation text"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="header"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="footer"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="index heading"/>
<w:LsdException Locked="false" Priority="35" SemiHidden="true"
UnhideWhenUsed="true" QFormat="true" Name="caption"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="table of figures"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="envelope address"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="envelope return"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="footnote reference"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="annotation reference"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="line number"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="page number"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="endnote reference"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="endnote text"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="table of authorities"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="macro"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="toa heading"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="List"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="List Bullet"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="List Number"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="List 2"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="List 3"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="List 4"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="List 5"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="List Bullet 2"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="List Bullet 3"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="List Bullet 4"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="List Bullet 5"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="List Number 2"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="List Number 3"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="List Number 4"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="List Number 5"/>
<w:LsdException Locked="false" Priority="10" QFormat="true" Name="Title"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="Closing"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="Signature"/>
<w:LsdException Locked="false" Priority="1" SemiHidden="true"
UnhideWhenUsed="true" Name="Default Paragraph Font"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="Body Text"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="Body Text Indent"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="List Continue"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="List Continue 2"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="List Continue 3"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="List Continue 4"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="List Continue 5"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="Message Header"/>
<w:LsdException Locked="false" Priority="11" QFormat="true" Name="Subtitle"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="Salutation"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="Date"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="Body Text First Indent"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="Body Text First Indent 2"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="Note Heading"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="Body Text 2"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="Body Text 3"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="Body Text Indent 2"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="Body Text Indent 3"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="Block Text"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="Hyperlink"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="FollowedHyperlink"/>
<w:LsdException Locked="false" Priority="22" QFormat="true" Name="Strong"/>
<w:LsdException Locked="false" Priority="20" QFormat="true" Name="Emphasis"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="Document Map"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="Plain Text"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="E-mail Signature"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="HTML Top of Form"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="HTML Bottom of Form"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="Normal (Web)"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="HTML Acronym"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="HTML Address"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="HTML Cite"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="HTML Code"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="HTML Definition"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="HTML Keyboard"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="HTML Preformatted"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="HTML Sample"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="HTML Typewriter"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="HTML Variable"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="Normal Table"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="annotation subject"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="No List"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="Outline List 1"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="Outline List 2"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="Outline List 3"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="Table Simple 1"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="Table Simple 2"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="Table Simple 3"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="Table Classic 1"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="Table Classic 2"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="Table Classic 3"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="Table Classic 4"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="Table Colorful 1"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="Table Colorful 2"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="Table Colorful 3"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="Table Columns 1"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="Table Columns 2"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="Table Columns 3"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="Table Columns 4"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="Table Columns 5"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="Table Grid 1"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="Table Grid 2"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="Table Grid 3"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="Table Grid 4"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="Table Grid 5"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="Table Grid 6"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="Table Grid 7"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="Table Grid 8"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="Table List 1"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="Table List 2"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="Table List 3"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="Table List 4"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="Table List 5"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="Table List 6"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="Table List 7"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="Table List 8"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="Table 3D effects 1"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="Table 3D effects 2"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="Table 3D effects 3"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="Table Contemporary"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="Table Elegant"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="Table Professional"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="Table Subtle 1"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="Table Subtle 2"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="Table Web 1"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="Table Web 2"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="Table Web 3"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="Balloon Text"/>
<w:LsdException Locked="false" Priority="39" Name="Table Grid"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="Table Theme"/>
<w:LsdException Locked="false" SemiHidden="true" Name="Placeholder Text"/>
<w:LsdException Locked="false" Priority="1" QFormat="true" Name="No Spacing"/>
<w:LsdException Locked="false" Priority="60" Name="Light Shading"/>
<w:LsdException Locked="false" Priority="61" Name="Light List"/>
<w:LsdException Locked="false" Priority="62" Name="Light Grid"/>
<w:LsdException Locked="false" Priority="63" Name="Medium Shading 1"/>
<w:LsdException Locked="false" Priority="64" Name="Medium Shading 2"/>
<w:LsdException Locked="false" Priority="65" Name="Medium List 1"/>
<w:LsdException Locked="false" Priority="66" Name="Medium List 2"/>
<w:LsdException Locked="false" Priority="67" Name="Medium Grid 1"/>
<w:LsdException Locked="false" Priority="68" Name="Medium Grid 2"/>
<w:LsdException Locked="false" Priority="69" Name="Medium Grid 3"/>
<w:LsdException Locked="false" Priority="70" Name="Dark List"/>
<w:LsdException Locked="false" Priority="71" Name="Colorful Shading"/>
<w:LsdException Locked="false" Priority="72" Name="Colorful List"/>
<w:LsdException Locked="false" Priority="73" Name="Colorful Grid"/>
<w:LsdException Locked="false" Priority="60" Name="Light Shading Accent 1"/>
<w:LsdException Locked="false" Priority="61" Name="Light List Accent 1"/>
<w:LsdException Locked="false" Priority="62" Name="Light Grid Accent 1"/>
<w:LsdException Locked="false" Priority="63" Name="Medium Shading 1 Accent 1"/>
<w:LsdException Locked="false" Priority="64" Name="Medium Shading 2 Accent 1"/>
<w:LsdException Locked="false" Priority="65" Name="Medium List 1 Accent 1"/>
<w:LsdException Locked="false" SemiHidden="true" Name="Revision"/>
<w:LsdException Locked="false" Priority="34" QFormat="true"
Name="List Paragraph"/>
<w:LsdException Locked="false" Priority="29" QFormat="true" Name="Quote"/>
<w:LsdException Locked="false" Priority="30" QFormat="true"
Name="Intense Quote"/>
<w:LsdException Locked="false" Priority="66" Name="Medium List 2 Accent 1"/>
<w:LsdException Locked="false" Priority="67" Name="Medium Grid 1 Accent 1"/>
<w:LsdException Locked="false" Priority="68" Name="Medium Grid 2 Accent 1"/>
<w:LsdException Locked="false" Priority="69" Name="Medium Grid 3 Accent 1"/>
<w:LsdException Locked="false" Priority="70" Name="Dark List Accent 1"/>
<w:LsdException Locked="false" Priority="71" Name="Colorful Shading Accent 1"/>
<w:LsdException Locked="false" Priority="72" Name="Colorful List Accent 1"/>
<w:LsdException Locked="false" Priority="73" Name="Colorful Grid Accent 1"/>
<w:LsdException Locked="false" Priority="60" Name="Light Shading Accent 2"/>
<w:LsdException Locked="false" Priority="61" Name="Light List Accent 2"/>
<w:LsdException Locked="false" Priority="62" Name="Light Grid Accent 2"/>
<w:LsdException Locked="false" Priority="63" Name="Medium Shading 1 Accent 2"/>
<w:LsdException Locked="false" Priority="64" Name="Medium Shading 2 Accent 2"/>
<w:LsdException Locked="false" Priority="65" Name="Medium List 1 Accent 2"/>
<w:LsdException Locked="false" Priority="66" Name="Medium List 2 Accent 2"/>
<w:LsdException Locked="false" Priority="67" Name="Medium Grid 1 Accent 2"/>
<w:LsdException Locked="false" Priority="68" Name="Medium Grid 2 Accent 2"/>
<w:LsdException Locked="false" Priority="69" Name="Medium Grid 3 Accent 2"/>
<w:LsdException Locked="false" Priority="70" Name="Dark List Accent 2"/>
<w:LsdException Locked="false" Priority="71" Name="Colorful Shading Accent 2"/>
<w:LsdException Locked="false" Priority="72" Name="Colorful List Accent 2"/>
<w:LsdException Locked="false" Priority="73" Name="Colorful Grid Accent 2"/>
<w:LsdException Locked="false" Priority="60" Name="Light Shading Accent 3"/>
<w:LsdException Locked="false" Priority="61" Name="Light List Accent 3"/>
<w:LsdException Locked="false" Priority="62" Name="Light Grid Accent 3"/>
<w:LsdException Locked="false" Priority="63" Name="Medium Shading 1 Accent 3"/>
<w:LsdException Locked="false" Priority="64" Name="Medium Shading 2 Accent 3"/>
<w:LsdException Locked="false" Priority="65" Name="Medium List 1 Accent 3"/>
<w:LsdException Locked="false" Priority="66" Name="Medium List 2 Accent 3"/>
<w:LsdException Locked="false" Priority="67" Name="Medium Grid 1 Accent 3"/>
<w:LsdException Locked="false" Priority="68" Name="Medium Grid 2 Accent 3"/>
<w:LsdException Locked="false" Priority="69" Name="Medium Grid 3 Accent 3"/>
<w:LsdException Locked="false" Priority="70" Name="Dark List Accent 3"/>
<w:LsdException Locked="false" Priority="71" Name="Colorful Shading Accent 3"/>
<w:LsdException Locked="false" Priority="72" Name="Colorful List Accent 3"/>
<w:LsdException Locked="false" Priority="73" Name="Colorful Grid Accent 3"/>
<w:LsdException Locked="false" Priority="60" Name="Light Shading Accent 4"/>
<w:LsdException Locked="false" Priority="61" Name="Light List Accent 4"/>
<w:LsdException Locked="false" Priority="62" Name="Light Grid Accent 4"/>
<w:LsdException Locked="false" Priority="63" Name="Medium Shading 1 Accent 4"/>
<w:LsdException Locked="false" Priority="64" Name="Medium Shading 2 Accent 4"/>
<w:LsdException Locked="false" Priority="65" Name="Medium List 1 Accent 4"/>
<w:LsdException Locked="false" Priority="66" Name="Medium List 2 Accent 4"/>
<w:LsdException Locked="false" Priority="67" Name="Medium Grid 1 Accent 4"/>
<w:LsdException Locked="false" Priority="68" Name="Medium Grid 2 Accent 4"/>
<w:LsdException Locked="false" Priority="69" Name="Medium Grid 3 Accent 4"/>
<w:LsdException Locked="false" Priority="70" Name="Dark List Accent 4"/>
<w:LsdException Locked="false" Priority="71" Name="Colorful Shading Accent 4"/>
<w:LsdException Locked="false" Priority="72" Name="Colorful List Accent 4"/>
<w:LsdException Locked="false" Priority="73" Name="Colorful Grid Accent 4"/>
<w:LsdException Locked="false" Priority="60" Name="Light Shading Accent 5"/>
<w:LsdException Locked="false" Priority="61" Name="Light List Accent 5"/>
<w:LsdException Locked="false" Priority="62" Name="Light Grid Accent 5"/>
<w:LsdException Locked="false" Priority="63" Name="Medium Shading 1 Accent 5"/>
<w:LsdException Locked="false" Priority="64" Name="Medium Shading 2 Accent 5"/>
<w:LsdException Locked="false" Priority="65" Name="Medium List 1 Accent 5"/>
<w:LsdException Locked="false" Priority="66" Name="Medium List 2 Accent 5"/>
<w:LsdException Locked="false" Priority="67" Name="Medium Grid 1 Accent 5"/>
<w:LsdException Locked="false" Priority="68" Name="Medium Grid 2 Accent 5"/>
<w:LsdException Locked="false" Priority="69" Name="Medium Grid 3 Accent 5"/>
<w:LsdException Locked="false" Priority="70" Name="Dark List Accent 5"/>
<w:LsdException Locked="false" Priority="71" Name="Colorful Shading Accent 5"/>
<w:LsdException Locked="false" Priority="72" Name="Colorful List Accent 5"/>
<w:LsdException Locked="false" Priority="73" Name="Colorful Grid Accent 5"/>
<w:LsdException Locked="false" Priority="60" Name="Light Shading Accent 6"/>
<w:LsdException Locked="false" Priority="61" Name="Light List Accent 6"/>
<w:LsdException Locked="false" Priority="62" Name="Light Grid Accent 6"/>
<w:LsdException Locked="false" Priority="63" Name="Medium Shading 1 Accent 6"/>
<w:LsdException Locked="false" Priority="64" Name="Medium Shading 2 Accent 6"/>
<w:LsdException Locked="false" Priority="65" Name="Medium List 1 Accent 6"/>
<w:LsdException Locked="false" Priority="66" Name="Medium List 2 Accent 6"/>
<w:LsdException Locked="false" Priority="67" Name="Medium Grid 1 Accent 6"/>
<w:LsdException Locked="false" Priority="68" Name="Medium Grid 2 Accent 6"/>
<w:LsdException Locked="false" Priority="69" Name="Medium Grid 3 Accent 6"/>
<w:LsdException Locked="false" Priority="70" Name="Dark List Accent 6"/>
<w:LsdException Locked="false" Priority="71" Name="Colorful Shading Accent 6"/>
<w:LsdException Locked="false" Priority="72" Name="Colorful List Accent 6"/>
<w:LsdException Locked="false" Priority="73" Name="Colorful Grid Accent 6"/>
<w:LsdException Locked="false" Priority="19" QFormat="true"
Name="Subtle Emphasis"/>
<w:LsdException Locked="false" Priority="21" QFormat="true"
Name="Intense Emphasis"/>
<w:LsdException Locked="false" Priority="31" QFormat="true"
Name="Subtle Reference"/>
<w:LsdException Locked="false" Priority="32" QFormat="true"
Name="Intense Reference"/>
<w:LsdException Locked="false" Priority="33" QFormat="true" Name="Book Title"/>
<w:LsdException Locked="false" Priority="37" SemiHidden="true"
UnhideWhenUsed="true" Name="Bibliography"/>
<w:LsdException Locked="false" Priority="39" SemiHidden="true"
UnhideWhenUsed="true" QFormat="true" Name="TOC Heading"/>
<w:LsdException Locked="false" Priority="41" Name="Plain Table 1"/>
<w:LsdException Locked="false" Priority="42" Name="Plain Table 2"/>
<w:LsdException Locked="false" Priority="43" Name="Plain Table 3"/>
<w:LsdException Locked="false" Priority="44" Name="Plain Table 4"/>
<w:LsdException Locked="false" Priority="45" Name="Plain Table 5"/>
<w:LsdException Locked="false" Priority="40" Name="Grid Table Light"/>
<w:LsdException Locked="false" Priority="46" Name="Grid Table 1 Light"/>
<w:LsdException Locked="false" Priority="47" Name="Grid Table 2"/>
<w:LsdException Locked="false" Priority="48" Name="Grid Table 3"/>
<w:LsdException Locked="false" Priority="49" Name="Grid Table 4"/>
<w:LsdException Locked="false" Priority="50" Name="Grid Table 5 Dark"/>
<w:LsdException Locked="false" Priority="51" Name="Grid Table 6 Colorful"/>
<w:LsdException Locked="false" Priority="52" Name="Grid Table 7 Colorful"/>
<w:LsdException Locked="false" Priority="46"
Name="Grid Table 1 Light Accent 1"/>
<w:LsdException Locked="false" Priority="47" Name="Grid Table 2 Accent 1"/>
<w:LsdException Locked="false" Priority="48" Name="Grid Table 3 Accent 1"/>
<w:LsdException Locked="false" Priority="49" Name="Grid Table 4 Accent 1"/>
<w:LsdException Locked="false" Priority="50" Name="Grid Table 5 Dark Accent 1"/>
<w:LsdException Locked="false" Priority="51"
Name="Grid Table 6 Colorful Accent 1"/>
<w:LsdException Locked="false" Priority="52"
Name="Grid Table 7 Colorful Accent 1"/>
<w:LsdException Locked="false" Priority="46"
Name="Grid Table 1 Light Accent 2"/>
<w:LsdException Locked="false" Priority="47" Name="Grid Table 2 Accent 2"/>
<w:LsdException Locked="false" Priority="48" Name="Grid Table 3 Accent 2"/>
<w:LsdException Locked="false" Priority="49" Name="Grid Table 4 Accent 2"/>
<w:LsdException Locked="false" Priority="50" Name="Grid Table 5 Dark Accent 2"/>
<w:LsdException Locked="false" Priority="51"
Name="Grid Table 6 Colorful Accent 2"/>
<w:LsdException Locked="false" Priority="52"
Name="Grid Table 7 Colorful Accent 2"/>
<w:LsdException Locked="false" Priority="46"
Name="Grid Table 1 Light Accent 3"/>
<w:LsdException Locked="false" Priority="47" Name="Grid Table 2 Accent 3"/>
<w:LsdException Locked="false" Priority="48" Name="Grid Table 3 Accent 3"/>
<w:LsdException Locked="false" Priority="49" Name="Grid Table 4 Accent 3"/>
<w:LsdException Locked="false" Priority="50" Name="Grid Table 5 Dark Accent 3"/>
<w:LsdException Locked="false" Priority="51"
Name="Grid Table 6 Colorful Accent 3"/>
<w:LsdException Locked="false" Priority="52"
Name="Grid Table 7 Colorful Accent 3"/>
<w:LsdException Locked="false" Priority="46"
Name="Grid Table 1 Light Accent 4"/>
<w:LsdException Locked="false" Priority="47" Name="Grid Table 2 Accent 4"/>
<w:LsdException Locked="false" Priority="48" Name="Grid Table 3 Accent 4"/>
<w:LsdException Locked="false" Priority="49" Name="Grid Table 4 Accent 4"/>
<w:LsdException Locked="false" Priority="50" Name="Grid Table 5 Dark Accent 4"/>
<w:LsdException Locked="false" Priority="51"
Name="Grid Table 6 Colorful Accent 4"/>
<w:LsdException Locked="false" Priority="52"
Name="Grid Table 7 Colorful Accent 4"/>
<w:LsdException Locked="false" Priority="46"
Name="Grid Table 1 Light Accent 5"/>
<w:LsdException Locked="false" Priority="47" Name="Grid Table 2 Accent 5"/>
<w:LsdException Locked="false" Priority="48" Name="Grid Table 3 Accent 5"/>
<w:LsdException Locked="false" Priority="49" Name="Grid Table 4 Accent 5"/>
<w:LsdException Locked="false" Priority="50" Name="Grid Table 5 Dark Accent 5"/>
<w:LsdException Locked="false" Priority="51"
Name="Grid Table 6 Colorful Accent 5"/>
<w:LsdException Locked="false" Priority="52"
Name="Grid Table 7 Colorful Accent 5"/>
<w:LsdException Locked="false" Priority="46"
Name="Grid Table 1 Light Accent 6"/>
<w:LsdException Locked="false" Priority="47" Name="Grid Table 2 Accent 6"/>
<w:LsdException Locked="false" Priority="48" Name="Grid Table 3 Accent 6"/>
<w:LsdException Locked="false" Priority="49" Name="Grid Table 4 Accent 6"/>
<w:LsdException Locked="false" Priority="50" Name="Grid Table 5 Dark Accent 6"/>
<w:LsdException Locked="false" Priority="51"
Name="Grid Table 6 Colorful Accent 6"/>
<w:LsdException Locked="false" Priority="52"
Name="Grid Table 7 Colorful Accent 6"/>
<w:LsdException Locked="false" Priority="46" Name="List Table 1 Light"/>
<w:LsdException Locked="false" Priority="47" Name="List Table 2"/>
<w:LsdException Locked="false" Priority="48" Name="List Table 3"/>
<w:LsdException Locked="false" Priority="49" Name="List Table 4"/>
<w:LsdException Locked="false" Priority="50" Name="List Table 5 Dark"/>
<w:LsdException Locked="false" Priority="51" Name="List Table 6 Colorful"/>
<w:LsdException Locked="false" Priority="52" Name="List Table 7 Colorful"/>
<w:LsdException Locked="false" Priority="46"
Name="List Table 1 Light Accent 1"/>
<w:LsdException Locked="false" Priority="47" Name="List Table 2 Accent 1"/>
<w:LsdException Locked="false" Priority="48" Name="List Table 3 Accent 1"/>
<w:LsdException Locked="false" Priority="49" Name="List Table 4 Accent 1"/>
<w:LsdException Locked="false" Priority="50" Name="List Table 5 Dark Accent 1"/>
<w:LsdException Locked="false" Priority="51"
Name="List Table 6 Colorful Accent 1"/>
<w:LsdException Locked="false" Priority="52"
Name="List Table 7 Colorful Accent 1"/>
<w:LsdException Locked="false" Priority="46"
Name="List Table 1 Light Accent 2"/>
<w:LsdException Locked="false" Priority="47" Name="List Table 2 Accent 2"/>
<w:LsdException Locked="false" Priority="48" Name="List Table 3 Accent 2"/>
<w:LsdException Locked="false" Priority="49" Name="List Table 4 Accent 2"/>
<w:LsdException Locked="false" Priority="50" Name="List Table 5 Dark Accent 2"/>
<w:LsdException Locked="false" Priority="51"
Name="List Table 6 Colorful Accent 2"/>
<w:LsdException Locked="false" Priority="52"
Name="List Table 7 Colorful Accent 2"/>
<w:LsdException Locked="false" Priority="46"
Name="List Table 1 Light Accent 3"/>
<w:LsdException Locked="false" Priority="47" Name="List Table 2 Accent 3"/>
<w:LsdException Locked="false" Priority="48" Name="List Table 3 Accent 3"/>
<w:LsdException Locked="false" Priority="49" Name="List Table 4 Accent 3"/>
<w:LsdException Locked="false" Priority="50" Name="List Table 5 Dark Accent 3"/>
<w:LsdException Locked="false" Priority="51"
Name="List Table 6 Colorful Accent 3"/>
<w:LsdException Locked="false" Priority="52"
Name="List Table 7 Colorful Accent 3"/>
<w:LsdException Locked="false" Priority="46"
Name="List Table 1 Light Accent 4"/>
<w:LsdException Locked="false" Priority="47" Name="List Table 2 Accent 4"/>
<w:LsdException Locked="false" Priority="48" Name="List Table 3 Accent 4"/>
<w:LsdException Locked="false" Priority="49" Name="List Table 4 Accent 4"/>
<w:LsdException Locked="false" Priority="50" Name="List Table 5 Dark Accent 4"/>
<w:LsdException Locked="false" Priority="51"
Name="List Table 6 Colorful Accent 4"/>
<w:LsdException Locked="false" Priority="52"
Name="List Table 7 Colorful Accent 4"/>
<w:LsdException Locked="false" Priority="46"
Name="List Table 1 Light Accent 5"/>
<w:LsdException Locked="false" Priority="47" Name="List Table 2 Accent 5"/>
<w:LsdException Locked="false" Priority="48" Name="List Table 3 Accent 5"/>
<w:LsdException Locked="false" Priority="49" Name="List Table 4 Accent 5"/>
<w:LsdException Locked="false" Priority="50" Name="List Table 5 Dark Accent 5"/>
<w:LsdException Locked="false" Priority="51"
Name="List Table 6 Colorful Accent 5"/>
<w:LsdException Locked="false" Priority="52"
Name="List Table 7 Colorful Accent 5"/>
<w:LsdException Locked="false" Priority="46"
Name="List Table 1 Light Accent 6"/>
<w:LsdException Locked="false" Priority="47" Name="List Table 2 Accent 6"/>
<w:LsdException Locked="false" Priority="48" Name="List Table 3 Accent 6"/>
<w:LsdException Locked="false" Priority="49" Name="List Table 4 Accent 6"/>
<w:LsdException Locked="false" Priority="50" Name="List Table 5 Dark Accent 6"/>
<w:LsdException Locked="false" Priority="51"
Name="List Table 6 Colorful Accent 6"/>
<w:LsdException Locked="false" Priority="52"
Name="List Table 7 Colorful Accent 6"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="Mention"/>
</w:LatentStyles>
</xml><![endif]--><!--[if gte mso 10]>
<style>
/* Style Definitions */
table.MsoNormalTable
{mso-style-name:"Table Normal";
mso-tstyle-rowband-size:0;
mso-tstyle-colband-size:0;
mso-style-noshow:yes;
mso-style-priority:99;
mso-style-parent:"";
mso-padding-alt:0cm 5.4pt 0cm 5.4pt;
mso-para-margin-top:0cm;
mso-para-margin-right:0cm;
mso-para-margin-bottom:10.0pt;
mso-para-margin-left:0cm;
line-height:115%;
mso-pagination:widow-orphan;
font-size:11.0pt;
font-family:"Calibri",sans-serif;
mso-ascii-font-family:Calibri;
mso-ascii-theme-font:minor-latin;
mso-hansi-font-family:Calibri;
mso-hansi-theme-font:minor-latin;
mso-fareast-language:EN-US;}
</style>
<![endif]--></div>
Dhruval Shahhttp://www.blogger.com/profile/10913767864566134668noreply@blogger.com0tag:blogger.com,1999:blog-7129929778341648750.post-33891343459952397772016-01-21T14:48:00.001+05:302016-01-21T14:48:19.004+05:30Translate Website to Another Language using Google Language API<div dir="ltr" style="text-align: left;" trbidi="on">
<div class="MsoNormal">
<b><span style="font-family: "times new roman" , serif; font-size: 18.0pt;">Create
An Enum Class <o:p></o:p></span></b></div>
<div class="MsoNormal">
<b><span style="font-family: "times new roman" , serif; font-size: 18.0pt;"><br /></span></b></div>
<div class="MsoNormal">
<span style="font-family: "times new roman" , serif; font-size: 12.0pt;">First, we will create our own </span><span style="font-family: "courier new"; font-size: 10.0pt;">enum
</span><span style="font-family: "times new roman" , serif; font-size: 12.0pt;">class for the languages based from
Google's Languages Enum, as mentioned and shown above. This is really
straight forward. See the code below: <o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "times new roman" , serif; font-size: 12.0pt;"><br /></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "courier new"; font-size: 10.0pt;">1
using System;<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "courier new"; font-size: 10.0pt;"> 2<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "courier new"; font-size: 10.0pt;"> 3 public class Language<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "courier new"; font-size: 10.0pt;"> 4 {<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "courier new"; font-size: 10.0pt;"> 5 public const string AFRIKAANS =
"af";<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "courier new"; font-size: 10.0pt;"> 6
public const string ALBANIAN = "sq";<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "courier new"; font-size: 10.0pt;"> 7
public const string AMHARIC = "am";<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "courier new"; font-size: 10.0pt;"> 8
public const string ARABIC = "ar";<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "courier new"; font-size: 10.0pt;"> 9
public const string ARMENIAN = "hy";<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "courier new"; font-size: 10.0pt;">10 public const string AZERBAIJANI = "az";<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "courier new"; font-size: 10.0pt;">11 public const string BASQUE =
"eu";<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "courier new"; font-size: 10.0pt;">12 public const string BELARUSIAN =
"be";<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "courier new"; font-size: 10.0pt;">13 public const string BENGALI =
"bn";<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "courier new"; font-size: 10.0pt;">14 public const string BIHARI =
"bh";<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "courier new"; font-size: 10.0pt;">15 public const string BULGARIAN =
"bg";<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "courier new"; font-size: 10.0pt;">16 public const string BURMESE =
"my";<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "courier new"; font-size: 10.0pt;">17 public const string CATALAN =
"ca";<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "courier new"; font-size: 10.0pt;">18 public const string CHEROKEE =
"chr";<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "courier new"; font-size: 10.0pt;">19 public const string CHINESE =
"zh";<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "courier new"; font-size: 10.0pt;">20 public const string CHINESE_SIMPLIFIED =
"zh-CN";<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "courier new"; font-size: 10.0pt;">21 public const string CHINESE_TRADITIONAL =
"zh-TW";<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "courier new"; font-size: 10.0pt;">22 public const string CROATIAN =
"hr";<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "courier new"; font-size: 10.0pt;">23 public const string CZECH =
"cs";<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "courier new"; font-size: 10.0pt;">24 public const string DANISH =
"da";<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "courier new"; font-size: 10.0pt;">25 public const string DHIVEHI =
"dv";<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "courier new"; font-size: 10.0pt;">26 public const string DUTCH =
"nl";<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "courier new"; font-size: 10.0pt;">27 public const string ENGLISH =
"en";<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "courier new"; font-size: 10.0pt;">28 public const string ESPERANTO =
"eo";<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "courier new"; font-size: 10.0pt;">29 public const string ESTONIAN =
"et";<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "courier new"; font-size: 10.0pt;">30 public const string FILIPINO =
"tl";<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "courier new"; font-size: 10.0pt;">31 public const string FINNISH =
"fi";<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "courier new"; font-size: 10.0pt;">32 public const string FRENCH =
"fr";<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "courier new"; font-size: 10.0pt;">33 public const string GALICIAN = "gl";<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "courier new"; font-size: 10.0pt;">34 public const string GEORGIAN =
"ka";<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "courier new"; font-size: 10.0pt;">35 public const string GERMAN =
"de";<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "courier new"; font-size: 10.0pt;">36 public const string GREEK =
"el";<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "courier new"; font-size: 10.0pt;">37 public const string GUARANI =
"gn";<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "courier new"; font-size: 10.0pt;">38 public const string GUJARATI =
"gu";<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "courier new"; font-size: 10.0pt;">39 public const string HEBREW = "iw";<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "courier new"; font-size: 10.0pt;">40 public const string HINDI =
"hi";<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "courier new"; font-size: 10.0pt;">41 public const string HUNGARIAN =
"hu";<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "courier new"; font-size: 10.0pt;">42 public const string ICELANDIC =
"is";<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "courier new"; font-size: 10.0pt;">43 public const string INDONESIAN =
"id";<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "courier new"; font-size: 10.0pt;">44 public const string INUKTITUT =
"iu";<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "courier new"; font-size: 10.0pt;">45 public const string ITALIAN =
"it";<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "courier new"; font-size: 10.0pt;">46 public const string JAPANESE =
"ja";<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "courier new"; font-size: 10.0pt;">47 public const string KANNADA =
"kn";<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "courier new"; font-size: 10.0pt;">48 public const string KAZAKH =
"kk";<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "courier new"; font-size: 10.0pt;">49 public const string KHMER =
"km";<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "courier new"; font-size: 10.0pt;">50 public const string KOREAN =
"ko";<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "courier new"; font-size: 10.0pt;">51 public const string KURDISH =
"ku";<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "courier new"; font-size: 10.0pt;">52 public const string KYRGYZ =
"ky";<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "courier new"; font-size: 10.0pt;">53 public const string LAOTHIAN =
"lo";<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "courier new"; font-size: 10.0pt;">54 public const string LATVIAN =
"lv";<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "courier new"; font-size: 10.0pt;">55 public const string LITHUANIAN =
"lt";<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "courier new"; font-size: 10.0pt;">56 public const string MACEDONIAN =
"mk";<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "courier new"; font-size: 10.0pt;">57 public const string MALAY =
"ms";<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "courier new"; font-size: 10.0pt;">58 public const string MALAYALAM =
"ml";<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "courier new"; font-size: 10.0pt;">59 public const string MALTESE =
"mt";<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "courier new"; font-size: 10.0pt;">60 public const string MARATHI =
"mr";<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "courier new"; font-size: 10.0pt;">61 public const string MONGOLIAN =
"mn";<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "courier new"; font-size: 10.0pt;">62 public const string NEPALI =
"ne";<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "courier new"; font-size: 10.0pt;">63 public const string NORWEGIAN =
"no";<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "courier new"; font-size: 10.0pt;">64 public const string ORIYA =
"or";<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "courier new"; font-size: 10.0pt;">65 public const string PASHTO =
"ps";<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "courier new"; font-size: 10.0pt;">66 public const string PERSIAN =
"fa";<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "courier new"; font-size: 10.0pt;">67 public const string POLISH =
"pl";<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "courier new"; font-size: 10.0pt;">68 public const string PORTUGUESE =
"pt-PT";<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "courier new"; font-size: 10.0pt;">69 public const string PUNJABI =
"pa";<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "courier new"; font-size: 10.0pt;">70 public const string ROMANIAN =
"ro";<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "courier new"; font-size: 10.0pt;">71 public const string RUSSIAN =
"ru";<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "courier new"; font-size: 10.0pt;">72 public const string SANSKRIT =
"sa";<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "courier new"; font-size: 10.0pt;">73 public const string SERBIAN =
"sr";<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "courier new"; font-size: 10.0pt;">74 public const string SINDHI = "sd";<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "courier new"; font-size: 10.0pt;">75 public const string SINHALESE =
"si";<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "courier new"; font-size: 10.0pt;">76 public const string SLOVAK =
"sk";<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "courier new"; font-size: 10.0pt;">77 public const string SLOVENIAN =
"sl";<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "courier new"; font-size: 10.0pt;">78 public const string SPANISH =
"es";<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "courier new"; font-size: 10.0pt;">79 public const string SWAHILI =
"sw";<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "courier new"; font-size: 10.0pt;">80 public const string SWEDISH =
"sv";<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "courier new"; font-size: 10.0pt;">81 public const string TAJIK =
"tg";<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "courier new"; font-size: 10.0pt;">82 public const string TAMIL =
"ta";<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "courier new"; font-size: 10.0pt;">83 public const string TAGALOG =
"tl";<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "courier new"; font-size: 10.0pt;">84 public const string TELUGU =
"te";<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "courier new"; font-size: 10.0pt;">85 public const string THAI = "th";<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "courier new"; font-size: 10.0pt;">86 public const string TIBETAN =
"bo";<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "courier new"; font-size: 10.0pt;">87 public const string TURKISH =
"tr";<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "courier new"; font-size: 10.0pt;">88 public const string UKRAINIAN =
"uk";<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "courier new"; font-size: 10.0pt;">89 public const string URDU = "ur";<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "courier new"; font-size: 10.0pt;">90 public const string UZBEK =
"uz";<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "courier new"; font-size: 10.0pt;">91 public const string UIGHUR =
"ug";<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "courier new"; font-size: 10.0pt;">92 public const string VIETNAMESE =
"vi";<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "courier new"; font-size: 10.0pt;">93 public const string UNKNOWN =
"";<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "courier new"; font-size: 10.0pt;">94<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "courier new"; font-size: 10.0pt;">95 public Language()<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "courier new"; font-size: 10.0pt;">96 {<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "courier new"; font-size: 10.0pt;">97 }<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "courier new"; font-size: 10.0pt;">98
}<o:p></o:p></span></div>
<div class="MsoNormal">
<br /></div>
<h2>
The Translation Method<o:p></o:p></h2>
We will also create a method that returns a translated <code><span style="font-size: 10.0pt;">string</span></code>. In this example, the method is
inside my test ASP.NET Page, that's why it's <code><span style="font-size: 10.0pt;">private</span></code>,
I recommend moving it to a <code><span style="font-size: 10.0pt;">public </span></code>class,
and make it <code><span style="font-size: 10.0pt;">static </span></code>so other
pages will have access to this method. <o:p></o:p><br />
<br />
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span lang="CS" style="font-family: "courier new"; font-size: 10.0pt;">30 private string Translate(string
stringToTranslate,<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span lang="CS" style="font-family: "courier new"; font-size: 10.0pt;">
string fromLanguage, string toLanguage)<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span lang="CS" style="font-family: "courier new"; font-size: 10.0pt;">31 {<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span lang="CS" style="font-family: "courier new"; font-size: 10.0pt;">32
// make sure that the passed string is not empty or null<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span lang="CS" style="font-family: "courier new"; font-size: 10.0pt;">33
if (!String.IsNullOrEmpty(stringToTranslate))<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span lang="CS" style="font-family: "courier new"; font-size: 10.0pt;">34
{<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span lang="CS" style="font-family: "courier new"; font-size: 10.0pt;">35 // per Google's terms of use, we can
only translate<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span lang="CS" style="font-family: "courier new"; font-size: 10.0pt;">36 // a string of up to 5000 characters
long<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span lang="CS" style="font-family: "courier new"; font-size: 10.0pt;">37
if (stringToTranslate.Length
<= 5000)<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span lang="CS" style="font-family: "courier new"; font-size: 10.0pt;">38 {<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span lang="CS" style="font-family: "courier new"; font-size: 10.0pt;">39 const int bufSizeMax = 65536;<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span lang="CS" style="font-family: "courier new"; font-size: 10.0pt;">40 const int bufSizeMin = 8192;<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span lang="CS" style="font-family: "courier new"; font-size: 10.0pt;">41<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span lang="CS" style="font-family: "courier new"; font-size: 10.0pt;">42 try<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span lang="CS" style="font-family: "courier new"; font-size: 10.0pt;">43 {<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span lang="CS" style="font-family: "courier new"; font-size: 10.0pt;">44 // by default format? is text.<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span lang="CS" style="font-family: "courier new"; font-size: 10.0pt;">
// so we don't need to send a format? key<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span lang="CS" style="font-family: "courier new"; font-size: 10.0pt;">45 string requestUri = "http://ajax.googleapis.com/<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span lang="CS" style="font-family: "courier new"; font-size: 10.0pt;">
ajax/services/language/translate?v=1.0&q=" +<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span lang="CS" style="font-family: "courier new"; font-size: 10.0pt;">46 stringToTranslate + "&langpair="
+<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span lang="CS" style="font-family: "courier new"; font-size: 10.0pt;">47 fromLanguage + "%7C"
+ toLanguage;<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span lang="CS" style="font-family: "courier new"; font-size: 10.0pt;">48<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span lang="CS" style="font-family: "courier new"; font-size: 10.0pt;">49 // execute the request and get
the response stream<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span lang="CS" style="font-family: "courier new"; font-size: 10.0pt;">50 HttpWebRequest request =<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span lang="CS" style="font-family: "courier new"; font-size: 10.0pt;">
(HttpWebRequest)WebRequest.Create(requestUri);<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span lang="CS" style="font-family: "courier new"; font-size: 10.0pt;">51 HttpWebResponse response =
(HttpWebResponse)request.GetResponse();<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span lang="CS" style="font-family: "courier new"; font-size: 10.0pt;">52 Stream responseStream =
response.GetResponseStream();<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span lang="CS" style="font-family: "courier new"; font-size: 10.0pt;">53<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span lang="CS" style="font-family: "courier new"; font-size: 10.0pt;">54 // get the length of the
content returned by the request<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span lang="CS" style="font-family: "courier new"; font-size: 10.0pt;">55 int length = (int)response.ContentLength;<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span lang="CS" style="font-family: "courier new"; font-size: 10.0pt;">56 int bufSize = bufSizeMin;<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span lang="CS" style="font-family: "courier new"; font-size: 10.0pt;">57<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span lang="CS" style="font-family: "courier new"; font-size: 10.0pt;">58 if (length > bufSize)<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span lang="CS" style="font-family: "courier new"; font-size: 10.0pt;">59 bufSize = length >
bufSizeMax ? bufSizeMax : length;<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span lang="CS" style="font-family: "courier new"; font-size: 10.0pt;">60<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span lang="CS" style="font-family: "courier new"; font-size: 10.0pt;">61 // allocate buffer and
StringBuilder for reading response<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span lang="CS" style="font-family: "courier new"; font-size: 10.0pt;">62 byte[] buf = new byte[bufSize];<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span lang="CS" style="font-family: "courier new"; font-size: 10.0pt;">63 StringBuilder sb = new
StringBuilder(bufSize);<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span lang="CS" style="font-family: "courier new"; font-size: 10.0pt;">64<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span lang="CS" style="font-family: "courier new"; font-size: 10.0pt;">65 // read the whole response<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span lang="CS" style="font-family: "courier new"; font-size: 10.0pt;">66 while ((length =
responseStream.Read(buf, 0, buf.Length)) != 0)<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span lang="CS" style="font-family: "courier new"; font-size: 10.0pt;">67 {<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span lang="CS" style="font-family: "courier new"; font-size: 10.0pt;">68
sb.Append(Encoding.UTF8.GetString(buf, 0, length));<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span lang="CS" style="font-family: "courier new"; font-size: 10.0pt;">69 }<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span lang="CS" style="font-family: "courier new"; font-size: 10.0pt;">70<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span lang="CS" style="font-family: "courier new"; font-size: 10.0pt;">71 // the format of the response
is like this<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span lang="CS" style="font-family: "courier new"; font-size: 10.0pt;">72 // {"responseData":
{"translatedText":"¿Cómo estás?"},<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span lang="CS" style="font-family: "courier new"; font-size: 10.0pt;"> "responseDetails": null,
"responseStatus": 200}<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span lang="CS" style="font-family: "courier new"; font-size: 10.0pt;">73 // so now let's clean up the
response by manipulating the string<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span lang="CS" style="font-family: "courier new"; font-size: 10.0pt;">74 string translatedText =
sb.Remove(0, 36).ToString();<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span lang="CS" style="font-family: "courier new"; font-size: 10.0pt;">75 translatedText =
translatedText.Substring(0,<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span lang="CS" style="font-family: "courier new"; font-size: 10.0pt;"> translatedText.IndexOf("\"},"));<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span lang="CS" style="font-family: "courier new"; font-size: 10.0pt;">76<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span lang="CS" style="font-family: "courier new"; font-size: 10.0pt;">77 return translatedText;<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span lang="CS" style="font-family: "courier new"; font-size: 10.0pt;">78 }<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span lang="CS" style="font-family: "courier new"; font-size: 10.0pt;">79 catch<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span lang="CS" style="font-family: "courier new"; font-size: 10.0pt;">80 {<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span lang="CS" style="font-family: "courier new"; font-size: 10.0pt;">81 return "Cannot get the
translation. Please try again
later.";<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span lang="CS" style="font-family: "courier new"; font-size: 10.0pt;">82 }<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span lang="CS" style="font-family: "courier new"; font-size: 10.0pt;">83 }<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span lang="CS" style="font-family: "courier new"; font-size: 10.0pt;">84 else<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span lang="CS" style="font-family: "courier new"; font-size: 10.0pt;">85 {<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span lang="CS" style="font-family: "courier new"; font-size: 10.0pt;">86 return "String to translate
must be less than 5000 characters long.";<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span lang="CS" style="font-family: "courier new"; font-size: 10.0pt;">87 }<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span lang="CS" style="font-family: "courier new"; font-size: 10.0pt;">88
}<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span lang="CS" style="font-family: "courier new"; font-size: 10.0pt;">89
else<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span lang="CS" style="font-family: "courier new"; font-size: 10.0pt;">90
{<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span lang="CS" style="font-family: "courier new"; font-size: 10.0pt;">91 return "String to translate is
empty.";<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span lang="CS" style="font-family: "courier new"; font-size: 10.0pt;">92
}<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span lang="CS" style="font-family: "courier new"; font-size: 10.0pt;">93 }<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span lang="CS" style="font-family: "courier new"; font-size: 10.0pt;"><br /></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span lang="CS" style="font-family: "courier new"; font-size: 10.0pt;"><br /></span></div>
<div class="MsoNormal">
<span style="font-family: "times new roman" , serif; font-size: 12.0pt;">Notice that the method accepts three
(3) parameters; the </span><span style="font-family: "courier new"; font-size: 10.0pt;">string </span><span style="font-family: "times new roman" , serif; font-size: 12.0pt;">to translate, the language to translate from, and the
language to translate to. The most important part of this code can be seen in
lines 45-52. Lines 45-47 build a URL that sends a request and gets the
response shown in lines 50-52. Because we're accessing the API via Google's
Rest Interface, the response is returned through a </span><span style="font-family: "courier new"; font-size: 10.0pt;">Stream
</span><span style="font-family: "times new roman" , serif; font-size: 12.0pt;">object. This is a lot easier to code
as compared to web services. The returned </span><span style="font-family: "courier new"; font-size: 10.0pt;">string </span><span style="font-family: "times new roman" , serif; font-size: 12.0pt;">encoded from the </span><span style="font-family: "courier new"; font-size: 10.0pt;">stream </span><span style="font-family: "times new roman" , serif; font-size: 12.0pt;">is cleaned-up (lines 74-75) and returned as the translated </span><span style="font-family: "courier new"; font-size: 10.0pt;">string</span><span style="font-family: "times new roman" , serif; font-size: 12.0pt;">. <o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "times new roman" , serif; font-size: 12.0pt;"><br /></span></div>
<div class="MsoNormal">
<b><span style="font-family: "times new roman" , serif; font-size: 18.0pt;">Ready
to Translate <o:p></o:p></span></b></div>
<div class="MsoNormal">
<b><span style="font-family: "times new roman" , serif; font-size: 18.0pt;"><br /></span></b></div>
<div class="MsoNormal">
<span style="font-family: "times new roman" , serif; font-size: 12.0pt;">Translating is again very straight
forward. We simply call the </span><span style="font-family: "courier new"; font-size: 10.0pt;">Translate </span><span style="font-family: "times new roman" , serif; font-size: 12.0pt;">method that we built above to get translated </span><span style="font-family: "courier new"; font-size: 10.0pt;">string</span><span style="font-family: "times new roman" , serif; font-size: 12.0pt;">s.</span></div>
<div class="MsoNormal">
<span style="font-family: "times new roman" , serif; font-size: 12.0pt;"><br /></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "courier new"; font-size: 10.0pt;"> <span lang="CS">9 protected
void Page_Load(object sender, EventArgs e)<o:p></o:p></span></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span lang="CS" style="font-family: "courier new"; font-size: 10.0pt;">10 {<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span lang="CS" style="font-family: "courier new"; font-size: 10.0pt;">11
string stringToTranslate = "Where do you live?<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span lang="CS" style="font-family: "courier new"; font-size: 10.0pt;"> What's your name? My name is Junnark.";<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span lang="CS" style="font-family: "courier new"; font-size: 10.0pt;">12
Response.Write("<b>English:</b> " +
stringToTranslate + "<br/><br/>");<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span lang="CS" style="font-family: "courier new"; font-size: 10.0pt;">13<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span lang="CS" style="font-family: "courier new"; font-size: 10.0pt;">14
string translatedString =<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span lang="CS" style="font-family: "courier new"; font-size: 10.0pt;">
Translate(stringToTranslate, Language.ENGLISH, Language.FILIPINO);<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span lang="CS" style="font-family: "courier new"; font-size: 10.0pt;">15
Response.Write("<b>Filipino:</b> " +
translatedString + "<br/><br/>");<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span lang="CS" style="font-family: "courier new"; font-size: 10.0pt;">16<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span lang="CS" style="font-family: "courier new"; font-size: 10.0pt;">17
translatedString =<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span lang="CS" style="font-family: "courier new"; font-size: 10.0pt;">
Translate(stringToTranslate, Language.ENGLISH, Language.SPANISH);<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span lang="CS" style="font-family: "courier new"; font-size: 10.0pt;">18
Response.Write("<b>Spanish:</b> " +
translatedString + "<br/><br/>");<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span lang="CS" style="font-family: "courier new"; font-size: 10.0pt;">19<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span lang="CS" style="font-family: "courier new"; font-size: 10.0pt;">20
translatedString =<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span lang="CS" style="font-family: "courier new"; font-size: 10.0pt;">
Translate(stringToTranslate, Language.ENGLISH, Language.CHINESE);<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span lang="CS" style="font-family: "courier new"; font-size: 10.0pt;">21
Response.Write("<b>Chinese:</b> " +
translatedString + "<br/><br/>");<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span lang="CS" style="font-family: "courier new"; font-size: 10.0pt;">22<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span lang="CS" style="font-family: "courier new"; font-size: 10.0pt;">23
translatedString =<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span lang="CS" style="font-family: "courier new"; font-size: 10.0pt;">
Translate(stringToTranslate, Language.ENGLISH, Language.FRENCH);<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span lang="CS" style="font-family: "courier new"; font-size: 10.0pt;">24
Response.Write("<b>French:</b> " +
translatedString + "<br/><br/>");<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span lang="CS" style="font-family: "courier new"; font-size: 10.0pt;">25<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span lang="CS" style="font-family: "courier new"; font-size: 10.0pt;">26
translatedString =<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span lang="CS" style="font-family: "courier new"; font-size: 10.0pt;">
Translate(stringToTranslate, Language.ENGLISH, Language.JAPANESE);<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span lang="CS" style="font-family: "courier new"; font-size: 10.0pt;">27
Response.Write("<b>Japanese:</b> " +
translatedString + "<br/><br/>");<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span lang="CS" style="font-family: "courier new"; font-size: 10.0pt;">28 }<o:p></o:p></span></div>
<br />
<div class="MsoNormal">
<br /></div>
</div>
Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-7129929778341648750.post-39444373915684428802012-10-10T17:36:00.003+05:302012-10-10T17:36:59.555+05:30Asynchronous call to MSSQL<div dir="ltr" style="text-align: left;" trbidi="on">
I was working on a small project that had a lot of computations happening in stored procedures.<br />
In beginning all worked fine, when there was increase in data the
stored procedure would take more time to complete the process and the
application would raise command timeout, once i increased the command
timeout of the connection it worked well but when again the data
increased it failed i had to increase the timeout much more.<br />
I thought it would not be feasible to increase the command timout to
max, so was searching for some alternate and found a nice concept called
“Asynchronous execution of the Transact-SQL” .<br />
This worked very fine and i was able to overcome the following issues<br />
<ul>
<li>No need to worry about command timeout</li>
<li>Other tasks can be done till MSSQL finishes executing the stored procedure</li>
</ul>
Here is the code i used for Asynchronous execution<br />
<pre style="border: #999999 1px dashed; color: black; line-height: 14px; overflow: auto; padding: 5px; width: 95%;"><span style="color: green; font-size: x-small;"><span style="font-size: small;"><span style="color: blue;">string</span><span> ConnectionString = </span><span style="color: #a31515;">@"Data Source=NAVEEN\SQLEXPRESS;Initial Catalog=Email;Integrated Security=True;Max Pool Size=5000;Connect Timeout=120; Asynchronous Processing=true"</span><span>;</span>
<span style="color: blue;">using</span><span> (</span><span style="color: #2b91af;">SqlConnection</span><span> sqlConn = </span><span style="color: blue;">new </span><span style="color: #2b91af;">SqlConnection</span><span>(ConnectionString))
{
sqlConn.Open();</span>
<span style="color: #2b91af;">SqlCommand</span><span> command = </span><span style="color: blue;">new </span><span style="color: #2b91af;">SqlCommand</span><span>(</span><span style="color: #a31515;">"ShiftNewEmails"</span><span>, sqlConn);
command.CommandType = </span><span style="color: #2b91af;">CommandType</span><span>.StoredProcedure;</span>
<span style="color: #2b91af;">IAsyncResult</span><span> asyncResult = command.BeginExecuteNonQuery();</span>
<span style="color: blue;">while</span><span> (!asyncResult.IsCompleted)
{
}</span>
<span style="color: #2b91af;">MessageBox</span><span>.Show(</span><span style="color: blue;">string</span><span>.Format(</span><span style="color: #a31515;">"Shifted {0} Email id's "</span></span><span style="font-size: xx-small;"><span style="font-size: small;">, command.EndExecuteNonQuery(asyncResult)));</span>
}</span>
</span></pre>
The key points to focus in the above code are<br />
<ul>
<li><strong>Asynchronous Processing=true</strong> -> in the connection string without this you cannot use Asynchronous execution.</li>
<li><strong>command.BeginExecuteNonQuery</strong>() -> Starts the execution of the stored procedure in asyn mode.</li>
<li><strong>asyncResult.IsCompleted</strong> -> Will be false till the mssql executes the command, once MSSQL finishes the value will be true.</li>
<li><strong>command.EndExecuteNonQuery(asyncResult)</strong>-> Gets the result of the execution from MSSQL in the asyncResult parameter and completes the task.</li>
</ul>
I did the following task while MSSQL is executing the command, this gave the user an idea that the process is working fine.<br />
<pre style="border: #999999 1px dashed; color: black; line-height: 14px; overflow: auto; padding: 5px; width: 95%;"><span style="color: green; font-size: x-small;"><span style="font-size: small;"><span style="color: blue;">int</span><span> FixedString = lblProcessing.Text.Length;</span>
<span style="color: blue;">int</span><span> Dots = 0;</span>
<span style="color: blue;">while</span><span> (!asyncResult.IsCompleted)
{</span>
<span style="color: blue;">if</span><span> (Dots > 10)
Dots = 0;
lblProcessing.Text = </span><span style="color: #a31515;">"Processing details please wait"</span><span>. PadRight(FixedString + Dots,</span><span style="color: #a31515;">'.'</span><span>);
Dots++;</span>
<span style="color: #2b91af;">Application</span><span>.DoEvents();</span>
<span style="color: #2b91af;">Thread</span><span>.Sleep(100);
}</span></span>
</span></pre>
So you can use this feature to make your application more user friendly and avoid program form showing “NOT RESPONDING”.</div>
Unknownnoreply@blogger.com1tag:blogger.com,1999:blog-7129929778341648750.post-29908724342964824112012-06-25T21:42:00.000+05:302012-06-25T21:42:26.029+05:30How to Declare a Value Type Variable<div dir="ltr" style="text-align: left;" trbidi="on">
<span style="font-family: arial;">To use a type, you must first declare a symbol as an instance of that type. Value types</span><br />
<span style="font-family: arial;">have an implicit constructor, so declaring them instantiates the type automatically; you</span><br />
<span style="font-family: arial;">don’t have to include the New keyword as you do with classes. The constructor assigns</span><br />
<span style="font-family: arial;">a default value (usually null or 0) to the new instance, but you should always explicitly</span><br />
<span style="font-family: arial;">initialize the variable within the declaration, as shown in the following code block:</span><br />
<br />
<br />
<span style="font-family: arial;">' VB</span><br />
<span style="font-family: arial;">Dim b As Boolean = False</span><br />
<br />
<span style="font-family: arial;">// C#</span><br />
<span style="font-family: arial;">bool b = false;</span><br />
<br />
Declare a variable as nullable if you want to be able to determine whether a value has<br />
been assigned. For example, if you are storing data from a yes/no question on a form<br />
and the user did not answer the question, you should store a null value. The following<br />
code declares a boolean variable that can be true, false, or null:<br />
<br />
' VB<br />
Dim b As Nullable(Of Boolean) = Nothing<br />
<br />
// C#<br />
Nullable//<bool> b = null;<br /><br />// Shorthand notation, only for C#<br />bool? b = null;<br /><br />Declaring a variable as nullable enables the HasValue and Value members. Use HasValue<br />to detect whether a value has been set as follows:<br /><br />' VB<br />If b.HasValue Then Console.WriteLine("b is {0}.", b.Value) _<br />Else Console.WriteLine("b is not set.")<br /><br />// C#<br />if (b.HasValue) Console.WriteLine("b is {0}.", b.Value);<br />else Console.WriteLine("b is not set.");<br /></bool></div>Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-7129929778341648750.post-90841726699674497702012-06-25T21:41:00.001+05:302012-06-25T21:41:57.862+05:30Encrypting QueryStrings with .NET<div dir="ltr" style="text-align: left;" trbidi="on">
<div class="Heading">
Encrypting QueryStrings with .NET</div>
<br />
<div class="Content">
Once upon a time in the tech world, obscurity was security - this being most true in the early years of the industry, when there were gaping holes in privacy policies and confidential client information was bandied about from site to site without a care as to who actually could read the information.<br />
With the new Cryptography classes in .NET, there's absolutely no excuse for not hiding even the most innocuous user data. If you ever need to 'piggy-back' information from one web page to another, whether it is within a POST or a GET parameter, you're passing clear information that anyone can sniff - and that's a bad thing.<br />
If you're not going to use a session variable for storing end user information, you're most likely going to keep some sort of State by passing the information to a cookie or push it around with GET/POST parameters. If you're passing around any sort of ID or user information like their name, it's better to err on the side of caution and encrypt the information.<br />
<b>GET Vs. POST</b><br />
A POST parameter keeps the information out of the URL, but it can still be sniffed quite easily as it passes in clear text across your network or the Internet. Using POST will keep the mere curious at bay, as the information is not contained in the URL - but this will not stop someone determined to snag out your data. <br />
A <code>QueryString</code> parameter passes information within the site's URL. Why would you even use a QueryString? Well, maybe you need to let your user bookmark a particular page, or maybe you have to refer directly to a page in a URL via a link - you can't do either if you're using POST. A QueryString puts data in the URL for the entire world to see, so if you don't know if the end user is malicious, I'd think hard about using a QueryString for anything but site-related information.<br />
<br />
Be smart and encrypt any and all data you're moving around from page to page, especially if that information could be used maliciously. You may trust your users, but you still need that extra level of security that clear text GET/POST data doesn't provide.Imagine this scenario - you've been passing the customer's ID in the database around in a QueryString, in a URL that looks like this:<br />
<br />
http://yoursite.com?cust_id=29<br />
<br />
You know what a user is going to do? Switch that 29 to a 30 or 12 or some other number, and if you're not checking for invalid requests, you'll be dishing up some other customer's data.<br />
<br />
<b>Enter Encryption</b><br />
What I was looking for was a quick way to encrypt and decrypt parts of a QueryString - it had to be on the fly, quick and dirty.<br />
I chose <code>Base64</code> because it wouldn't throw bizarre characters in my QueryString that I couldn't pass around… Little did I know that I'd hit a snag while passing around my encrypted QueryString - Apparently, the <code>Request.QueryString</code> object interprets the '+' sign as a space! So, with a quick <code>Replace</code> function slapped on my decrypt string, no harm, no foul.<br />
<b>Symmetric Key</b><br />
The whole trick to this working is that the QueryString is encrypted and decrypted with the same private key. This is the secret key - if anyone gets a hold of your key, they can decrypt the data themselves, so keep it a secret!<br />
We're going to use a hard-to-crack 8 byte key, !#$a54?3, to keep parts of our QueryString secret.<br />
<i>Let's Walk through the C# portion of the code:</i><br />
Notice our two functions that abstract the dirty work that our <code>Encryption64</code> class. The first, <code>encryptQueryString</code>, is used to encrypt the value of a QueryString. The second, <code>decryptQueryString</code>, is used to decrypt the value of an encrypted QueryString.<br />
<blockquote>
<pre class="code"><span style="color: blue;">public string</span> <span style="color: black;">encryptQueryString</span><span style="color: #804040;">(</span><span style="color: blue;">string</span> <span style="color: black;">strQueryString</span><span style="color: #804040;">) {</span>
<span style="color: black;">ExtractAndSerialize</span><span style="color: #804040;">.</span><span style="color: black;">Encryption64 oES</span> <span style="color: #804040;">=</span>
<span style="color: blue;">new</span> <span style="color: black;">ExtractAndSerialize</span><span style="color: #804040;">.</span><span style="color: black;">Encryption64</span><span style="color: #804040;">();</span>
<span style="color: blue;">return</span> <span style="color: black;">oES</span><span style="color: #804040;">.</span><span style="color: black;">Encrypt</span><span style="color: #804040;">(</span><span style="color: black;">strQueryString</span><span style="color: #804040;">,</span><span style="color: magenta;">"!#$a54?3"</span><span style="color: #804040;">);</span>
<span style="color: #804040;">}</span>
<span style="color: #804040;">
</span><span style="color: blue;">public string</span> <span style="color: black;">decryptQueryString</span><span style="color: #804040;">(</span><span style="color: blue;">string</span> <span style="color: black;">strQueryString</span><span style="color: #804040;">) {</span>
<span style="color: black;">ExtractAndSerialize</span><span style="color: #804040;">.</span><span style="color: black;">Encryption64 oES</span> <span style="color: #804040;">=</span>
<span style="color: blue;">new</span> <span style="color: black;">ExtractAndSerialize</span><span style="color: #804040;">.</span><span style="color: black;">Encryption64</span><span style="color: #804040;">();</span>
<span style="color: blue;">return</span> <span style="color: black;">oES</span><span style="color: #804040;">.</span><span style="color: black;">Decrypt</span><span style="color: #804040;">(</span><span style="color: black;">strQueryString</span><span style="color: #804040;">,</span><span style="color: magenta;">"!#$a54?3"</span><span style="color: #804040;">);</span>
<span style="color: #804040;">}</span></pre>
</blockquote>
If we wanted to encrypt our QueryString on our first page, we could do something like this:<br />
<blockquote>
<pre class="code"><span style="color: blue;">string</span> <span style="color: black;">strValues</span> <span style="color: #804040;">=</span> <span style="color: magenta;">"search term"</span><span style="color: #804040;">;
</span><span style="color: blue;">string</span> <span style="color: black;">strURL</span> <span style="color: #804040;">=</span> <span style="color: magenta;">"http://yoursite.com?search="</span>
<span style="color: #804040;">+</span> <span style="color: black;">encryptQueryString</span><span style="color: #804040;">(</span><span style="color: black;">strValues</span><span style="color: #804040;">);</span><span style="color: black;">Response</span><span style="color: #804040;">.</span><span style="color: black;">Redirect</span><span style="color: #804040;">(</span><span style="color: black;">strURL</span><span style="color: #804040;">);</span></pre>
</blockquote>
Inside our code-behind in our second page, we pass the contents our QueryString to a variable named <code>strScramble</code>. After that, we replace the '+' signs that our wonderful <code>Request.QueryString</code> has replaced with a space. We pass that string into our function, <code>decryptQueryString</code>, and retrieve the decrypted string.<br />
<blockquote>
<pre class="code"><span style="color: blue;">string</span> <span style="color: black;">strScramble</span> <span style="color: #804040;">=</span> <span style="color: black;">Request</span><span style="color: #804040;">.</span><span style="color: black;">QueryString</span><span style="color: #804040;">[</span><span style="color: magenta;">"search"</span><span style="color: #804040;">];
</span><span style="color: blue;">string</span> <span style="color: black;">strdeCrypt</span> <span style="color: #804040;">=</span> <span style="color: black;">decryptQueryString</span><span style="color: #804040;">(</span>
<span style="color: black;">strScramble</span><span style="color: #804040;">.</span><span style="color: black;">Replace</span><span style="color: #804040;">(</span><span style="color: magenta;">" "</span><span style="color: #804040;">,</span> <span style="color: magenta;">"+"</span><span style="color: #804040;">));</span></pre>
</blockquote>
Now we've decrypted the value of the QueryString, 'search', and we can do whatever we want with it. The end user is going to see a URL that looks like:<br />
<br />
<br />
<blockquote>
<br />
<pre>http://yoursite.com?search=da00992Lo39+343dw</pre>
<br /></blockquote>
<br />
<br />
They'll never be able guess what's going on in your QueryString, and if they try to fool around with it, there's no way to crack the code without knowing the Symmetric key. <br />
<br />
<br />
<br />
<b>VB.NET</b><br />
<span style="color: blue;">Imports</span> <span style="color: teal;">System</span><br /><span style="color: blue;">Imports</span> <span style="color: teal;">System</span><span style="color: black;">.</span><span style="color: teal;">IO</span><br /><span style="color: blue;">Imports</span> <span style="color: teal;">System</span><span style="color: black;">.</span><span style="color: teal;">Xml</span><br /><br /><span style="color: blue;">Imports</span> <span style="color: teal;">System</span><span style="color: black;">.</span><span style="color: black;">Text</span><br /><span style="color: blue;">Imports</span> <span style="color: teal;">System</span><span style="color: black;">.</span><span style="color: black;">Security</span><span style="color: black;">.</span><span style="color: black;">Cryptography</span><br /><br /><span style="color: blue;">Public</span> <span style="color: blue;">Class</span> <span style="color: black;">Encryption64</span><br /><br /> <span style="color: blue;">Private</span> <span style="color: black;">key</span><span style="color: black;">() </span><span style="color: blue;">As</span> <span style="color: teal;">Byte</span> <span style="color: #804040;">=</span> <span style="color: black;">{}</span><br /> <span style="color: blue;">Private</span> <span style="color: black;">IV</span><span style="color: black;">() </span><span style="color: blue;">As</span> <span style="color: teal;">Byte</span> <span style="color: #804040;">=</span> <span style="color: black;">{&H12</span><span style="color: black;">, </span><span style="color: black;">&H34</span><span style="color: black;">, </span><span style="color: black;">&H56</span><span style="color: black;">, </span><span style="color: black;">&H78</span><span style="color: black;">, </span><span style="color: black;">&H90</span><span style="color: black;">, </span><span style="color: black;">&HAB</span><span style="color: black;">, </span><span style="color: black;">&HCD</span><span style="color: black;">, </span><span style="color: black;">&HEF}</span><br /><br /> <span style="color: blue;">Public</span> <span style="color: blue;">Function</span> <span style="color: black;">Decrypt</span><span style="color: black;">(</span><span style="color: blue;">ByVal</span> <span style="color: black;">stringToDecrypt</span> <span style="color: blue;">As</span> <span style="color: teal;">String</span><span style="color: black;">, </span><span style="color: black;">_</span><br /> <span style="color: blue;">ByVal</span> <span style="color: black;">sEncryptionKey</span> <span style="color: blue;">As</span> <span style="color: teal;">String</span><span style="color: black;">) </span><span style="color: blue;">As</span> <span style="color: teal;">String</span><br /><br /> <span style="color: blue;">Dim</span> <span style="color: black;">inputByteArray</span><span style="color: black;">(</span><span style="color: black;">stringToDecrypt</span><span style="color: black;">.</span><span style="color: black;">Length</span><span style="color: black;">) </span><span style="color: blue;">As</span> <span style="color: teal;">Byte</span><br /> <span style="color: blue;">Try</span><br /> <span style="color: black;">key</span> <span style="color: #804040;">=</span> <span style="color: teal;">System</span><span style="color: black;">.</span><span style="color: black;">Text</span><span style="color: black;">.</span><span style="color: black;">Encoding</span><span style="color: black;">.</span><span style="color: black;">UTF8</span><span style="color: black;">.</span><span style="color: black;">GetBytes</span><span style="color: black;">(</span><span style="color: navy;">Left</span><span style="color: black;">(</span><span style="color: black;">sEncryptionKey</span><span style="color: black;">, </span><span style="color: black;">8</span><span style="color: black;">))</span><br /><br /> <span style="color: blue;">Dim</span> <span style="color: black;">des</span> <span style="color: blue;">As</span> <span style="color: blue;">New</span> <span style="color: black;">DESCryptoServiceProvider</span><span style="color: black;">()</span><br /> <span style="color: black;">inputByteArray</span> <span style="color: #804040;">=</span> <span style="color: teal;">Convert</span><span style="color: black;">.</span><span style="color: black;">FromBase64String</span><span style="color: black;">(</span><span style="color: black;">stringToDecrypt</span><span style="color: black;">)</span><br /> <span style="color: blue;">Dim</span> <span style="color: black;">ms</span> <span style="color: blue;">As</span> <span style="color: blue;">New</span> <span style="color: teal;">MemoryStream</span><span style="color: black;">()</span><br /><br /> <span style="color: blue;">Dim</span> <span style="color: black;">cs</span> <span style="color: blue;">As</span> <span style="color: blue;">New</span> <span style="color: black;">CryptoStream</span><span style="color: black;">(</span><span style="color: black;">ms</span><span style="color: black;">, </span><span style="color: black;">des</span><span style="color: black;">.</span><span style="color: black;">CreateDecryptor</span><span style="color: black;">(</span><span style="color: black;">key</span><span style="color: black;">, </span><span style="color: black;">IV</span><span style="color: black;">), </span><span style="color: black;">_</span><br /><br /> <span style="color: black;">CryptoStreamMode</span><span style="color: black;">.</span><span style="color: black;">Write</span><span style="color: black;">)</span><br /> <span style="color: black;">cs</span><span style="color: black;">.</span><span style="color: black;">Write</span><span style="color: black;">(</span><span style="color: black;">inputByteArray</span><span style="color: black;">, </span><span style="color: black;">0</span><span style="color: black;">, </span><span style="color: black;">inputByteArray</span><span style="color: black;">.</span><span style="color: black;">Length</span><span style="color: black;">)</span><br /><br /> <span style="color: black;">cs</span><span style="color: black;">.</span><span style="color: black;">FlushFinalBlock</span><span style="color: black;">()</span><br /> <span style="color: blue;">Dim</span> <span style="color: black;">encoding</span> <span style="color: blue;">As</span> <span style="color: teal;">System</span><span style="color: black;">.</span><span style="color: black;">Text</span><span style="color: black;">.</span><span style="color: black;">Encoding</span> <span style="color: #804040;">=</span> <span style="color: teal;">System</span><span style="color: black;">.</span><span style="color: black;">Text</span><span style="color: black;">.</span><span style="color: black;">Encoding</span><span style="color: black;">.</span><span style="color: black;">UTF8</span><br /><br /> <span style="color: blue;">Return</span> <span style="color: black;">encoding</span><span style="color: black;">.</span><span style="color: black;">GetString</span><span style="color: black;">(</span><span style="color: black;">ms</span><span style="color: black;">.</span><span style="color: black;">ToArray</span><span style="color: black;">())</span><br /> <span style="color: blue;">Catch</span> <span style="color: black;">e</span> <span style="color: blue;">As</span> <span style="color: teal;">Exception</span><br /> <span style="color: blue;">Return</span> <span style="color: black;">e</span><span style="color: black;">.</span><span style="color: teal;">Message</span><br /><br /> <span style="color: blue;">End</span> <span style="color: blue;">Try</span><br /> <span style="color: blue;">End</span> <span style="color: blue;">Function</span><br /><br /> <span style="color: blue;">Public</span> <span style="color: blue;">Function</span> <span style="color: black;">Encrypt</span><span style="color: black;">(</span><span style="color: blue;">ByVal</span> <span style="color: black;">stringToEncrypt</span> <span style="color: blue;">As</span> <span style="color: teal;">String</span><span style="color: black;">, </span><span style="color: black;">_</span><br /><br /> <span style="color: blue;">ByVal</span> <span style="color: black;">SEncryptionKey</span> <span style="color: blue;">As</span> <span style="color: teal;">String</span><span style="color: black;">) </span><span style="color: blue;">As</span> <span style="color: teal;">String</span><br /> <span style="color: blue;">Try</span><br /> <span style="color: black;">key</span> <span style="color: #804040;">=</span> <span style="color: teal;">System</span><span style="color: black;">.</span><span style="color: black;">Text</span><span style="color: black;">.</span><span style="color: black;">Encoding</span><span style="color: black;">.</span><span style="color: black;">UTF8</span><span style="color: black;">.</span><span style="color: black;">GetBytes</span><span style="color: black;">(</span><span style="color: navy;">Left</span><span style="color: black;">(</span><span style="color: black;">SEncryptionKey</span><span style="color: black;">, </span><span style="color: black;">8</span><span style="color: black;">))</span><br /><br /> <span style="color: blue;">Dim</span> <span style="color: black;">des</span> <span style="color: blue;">As</span> <span style="color: blue;">New</span> <span style="color: black;">DESCryptoServiceProvider</span><span style="color: black;">()</span><br /> <span style="color: blue;">Dim</span> <span style="color: black;">inputByteArray</span><span style="color: black;">() </span><span style="color: blue;">As</span> <span style="color: teal;">Byte</span> <span style="color: #804040;">=</span> <span style="color: black;">Encoding</span><span style="color: black;">.</span><span style="color: black;">UTF8</span><span style="color: black;">.</span><span style="color: black;">GetBytes</span><span style="color: black;">( </span><span style="color: black;">_</span><br /><br /> <span style="color: black;">stringToEncrypt</span><span style="color: black;">)</span><br /> <span style="color: blue;">Dim</span> <span style="color: black;">ms</span> <span style="color: blue;">As</span> <span style="color: blue;">New</span> <span style="color: teal;">MemoryStream</span><span style="color: black;">()</span><br /> <span style="color: blue;">Dim</span> <span style="color: black;">cs</span> <span style="color: blue;">As</span> <span style="color: blue;">New</span> <span style="color: black;">CryptoStream</span><span style="color: black;">(</span><span style="color: black;">ms</span><span style="color: black;">, </span><span style="color: black;">des</span><span style="color: black;">.</span><span style="color: black;">CreateEncryptor</span><span style="color: black;">(</span><span style="color: black;">key</span><span style="color: black;">, </span><span style="color: black;">IV</span><span style="color: black;">), </span><span style="color: black;">_</span><br /><br /> <span style="color: black;">CryptoStreamMode</span><span style="color: black;">.</span><span style="color: black;">Write</span><span style="color: black;">)</span><br /> <span style="color: black;">cs</span><span style="color: black;">.</span><span style="color: black;">Write</span><span style="color: black;">(</span><span style="color: black;">inputByteArray</span><span style="color: black;">, </span><span style="color: black;">0</span><span style="color: black;">, </span><span style="color: black;">inputByteArray</span><span style="color: black;">.</span><span style="color: black;">Length</span><span style="color: black;">)</span><br /><br /> <span style="color: black;">cs</span><span style="color: black;">.</span><span style="color: black;">FlushFinalBlock</span><span style="color: black;">()</span><br /> <span style="color: blue;">Return</span> <span style="color: teal;">Convert</span><span style="color: black;">.</span><span style="color: black;">ToBase64String</span><span style="color: black;">(</span><span style="color: black;">ms</span><span style="color: black;">.</span><span style="color: black;">ToArray</span><span style="color: black;">())</span><br /> <span style="color: blue;">Catch</span> <span style="color: black;">e</span> <span style="color: blue;">As</span> <span style="color: teal;">Exception</span><br /><br /> <span style="color: blue;">Return</span> <span style="color: black;">e</span><span style="color: black;">.</span><span style="color: teal;">Message</span><br /> <span style="color: blue;">End</span> <span style="color: blue;">Try</span><br /> <span style="color: blue;">End</span> <span style="color: blue;">Function</span><br /><br /><span style="color: blue;">End</span> <span style="color: blue;">Class</span></div>
</div>Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-7129929778341648750.post-72833572589000159802012-06-25T15:48:00.001+05:302012-06-25T15:55:49.528+05:30Crystal Reports In ASP.NET<div dir="ltr" style="text-align: left;" trbidi="on">
<div dir="ltr" style="text-align: left;" trbidi="on">
<div style="text-align: left;">
</div>
<div class="separator" style="clear: both; text-align: left;">
This example shows how to <b>Create Crystal Reports In ASP.NET 2.0,3.5,4.0 Using C# And VB.NET.</b>
I am generating Crystal report by fetching data from two tables and
grouping them based on Project Name. Database tables are just for demo
purpose you can create your own tables with whatever schema you want </div>
<br />
Two tables are as shown below.<br />
<div class="separator" style="clear: both; text-align: left;">
</div>
<div class="separator" style="clear: both; text-align: left;">
<a href="http://3.bp.blogspot.com/-9oauIgZmclY/T-g2ysMltKI/AAAAAAAAAq4/1iBMwBdOheI/s1600/6.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="115" src="http://3.bp.blogspot.com/-9oauIgZmclY/T-g2ysMltKI/AAAAAAAAAq4/1iBMwBdOheI/s320/6.JPG" width="320" /></a></div>
<div class="separator" style="clear: both; text-align: left;">
<a href="http://1.bp.blogspot.com/-C26gI-0JIUo/T-g20Crb85I/AAAAAAAAArA/kJJ_qA-BOSM/s1600/7.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://1.bp.blogspot.com/-C26gI-0JIUo/T-g20Crb85I/AAAAAAAAArA/kJJ_qA-BOSM/s1600/7.JPG" /></a></div>
<div style="text-align: left;">
<br /></div>
<div style="text-align: left;">
<br /></div>
<div style="text-align: left;">
<span class="fullpost">Create a new website and right click on solution explorer > add new Item > Select Crystal Report<br />
In the dialog box choose blank report.</span></div>
<div style="text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
<a href="http://3.bp.blogspot.com/-altzk-F2evQ/T-g21Qt2mcI/AAAAAAAAArI/Oa0RfGvpfEo/s1600/8.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="320" src="http://3.bp.blogspot.com/-altzk-F2evQ/T-g21Qt2mcI/AAAAAAAAArI/Oa0RfGvpfEo/s320/8.JPG" width="262" /></a></div>
<div style="text-align: left;">
<br /></div>
<div style="text-align: left;">
<span class="fullpost">Now click on CrystalReports Menu in VS and select DataBase Expert </span></div>
<div style="text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
<a href="http://4.bp.blogspot.com/-y5NGYyIAdkM/T-g22cERI9I/AAAAAAAAArQ/zCuia0laGAY/s1600/9.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://4.bp.blogspot.com/-y5NGYyIAdkM/T-g22cERI9I/AAAAAAAAArQ/zCuia0laGAY/s1600/9.JPG" /></a></div>
<div style="text-align: left;">
<br /></div>
<div style="text-align: left;">
<span class="fullpost">In database expert dialog box expend create new connection > OLEDB(ADO) section </span></div>
<div class="separator" style="clear: both; text-align: left;">
<a href="http://4.bp.blogspot.com/-S5Wnes1OpqE/T-g23sHAC2I/AAAAAAAAArY/0iO3pVuFclg/s1600/10.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://4.bp.blogspot.com/-S5Wnes1OpqE/T-g23sHAC2I/AAAAAAAAArY/0iO3pVuFclg/s1600/10.JPG" /></a></div>
<div style="text-align: left;">
<br /></div>
<div style="text-align: left;">
<br /></div>
<div style="text-align: left;">
<span class="fullpost">Now select SQL Native client and enter you SQL server address , username , password and pick database name from the dropdown. </span></div>
<div class="separator" style="clear: both; text-align: left;">
<a href="http://1.bp.blogspot.com/-2by3fMsTLYk/T-g24mE8WmI/AAAAAAAAArc/NSmYMXH130c/s1600/11.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://1.bp.blogspot.com/-2by3fMsTLYk/T-g24mE8WmI/AAAAAAAAArc/NSmYMXH130c/s1600/11.JPG" /></a></div>
<div style="text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
<a href="http://1.bp.blogspot.com/-dPVabwXZQCE/T-g25a-a0OI/AAAAAAAAAro/l-yLmEzuoDw/s1600/12.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://1.bp.blogspot.com/-dPVabwXZQCE/T-g25a-a0OI/AAAAAAAAAro/l-yLmEzuoDw/s1600/12.JPG" /></a></div>
<div style="text-align: left;">
<br /></div>
<div style="text-align: left;">
<br /></div>
<div style="text-align: left;">
<span class="fullpost">In next screen Expend your database objects in left pane and add the tables you want to use in right pane </span></div>
<div class="separator" style="clear: both; text-align: left;">
<a href="http://3.bp.blogspot.com/-EgFgxG7x4i4/T-g26DRWwUI/AAAAAAAAArs/zK0XKUiDdSE/s1600/13.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="309" src="http://3.bp.blogspot.com/-EgFgxG7x4i4/T-g26DRWwUI/AAAAAAAAArs/zK0XKUiDdSE/s320/13.JPG" width="320" /></a></div>
<div style="text-align: left;">
<br /></div>
<div style="text-align: left;">
<span class="fullpost">Link your tables based on Primary keys (If any)</span></div>
<div style="text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
<a href="http://1.bp.blogspot.com/-tSYuWV68HTg/T-g268hHByI/AAAAAAAAAr4/KSTNBZxgjuc/s1600/14.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://1.bp.blogspot.com/-tSYuWV68HTg/T-g268hHByI/AAAAAAAAAr4/KSTNBZxgjuc/s1600/14.JPG" /></a></div>
<div style="text-align: left;">
<br /></div>
<div style="text-align: left;">
<br /></div>
<div style="text-align: left;">
<span class="fullpost">Click ok to finish the wizard.<br />
Right click on Field Explorer and select Group Name Fields > Insert Group </span></div>
<div class="separator" style="clear: both; text-align: left;">
<a href="http://4.bp.blogspot.com/-L32IN0bcrvg/T-g28b8gcuI/AAAAAAAAAsA/RDkRZKjY9Xg/s1600/15.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://4.bp.blogspot.com/-L32IN0bcrvg/T-g28b8gcuI/AAAAAAAAAsA/RDkRZKjY9Xg/s1600/15.JPG" /></a></div>
<div style="text-align: left;">
<br /></div>
<div style="text-align: left;">
<span class="fullpost">In next box select the field you to report to be grouped (in my case it's ProjectsName)</span></div>
<div class="separator" style="clear: both; text-align: left;">
<a href="http://4.bp.blogspot.com/-_KBz5hbqkQI/T-g29a-rxaI/AAAAAAAAAsI/7oUwq2Kw3nU/s1600/16.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://4.bp.blogspot.com/-_KBz5hbqkQI/T-g29a-rxaI/AAAAAAAAAsI/7oUwq2Kw3nU/s1600/16.JPG" /></a></div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
</div>
<div style="text-align: left;">
<br /></div>
<div style="text-align: left;">
<span class="fullpost">Click on OK to finish<br />
Now design the report , drag and fields from Database fields in field
explorer and which you want to show in report and drop them in <b>Section3(Details), </b>and preview the report<b>, </b>it should look like show below<b>.</b></span></div>
<div class="separator" style="clear: both; text-align: left;">
<a href="http://4.bp.blogspot.com/-8KLyaKF2iFk/T-g2-i6-1nI/AAAAAAAAAsU/nW8TWjgEI1E/s1600/17.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="177" src="http://4.bp.blogspot.com/-8KLyaKF2iFk/T-g2-i6-1nI/AAAAAAAAAsU/nW8TWjgEI1E/s320/17.JPG" width="320" /></a></div>
<div class="separator" style="clear: both; text-align: left;">
</div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
<span class="fullpost">Go to default.aspx page and drag and drop CrystalReportViewer from the toolbox, click on smart tag and choose new report source.</span></div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
</div>
<div class="separator" style="clear: both; text-align: left;">
<a href="http://3.bp.blogspot.com/-QIQikXv4ykE/T-g5DS6qeWI/AAAAAAAAAs0/e_BIfwsGpF8/s1600/21.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://3.bp.blogspot.com/-QIQikXv4ykE/T-g5DS6qeWI/AAAAAAAAAs0/e_BIfwsGpF8/s1600/21.JPG" /></a></div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div style="text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
<a href="http://1.bp.blogspot.com/-1DjAV3-yOuo/T-g2_RzkpqI/AAAAAAAAAsY/X5ra9wv9MTw/s1600/18.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://1.bp.blogspot.com/-1DjAV3-yOuo/T-g2_RzkpqI/AAAAAAAAAsY/X5ra9wv9MTw/s1600/18.JPG" /></a></div>
<div style="text-align: left;">
<br /></div>
<div style="text-align: left;">
<br /></div>
<div style="text-align: left;">
<span class="fullpost">Choose you report from the dropdown menu and click ok to finish.<br />
Now when you build and run the sample , it asks for the database password everytime</span></div>
<div style="text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
<a href="http://3.bp.blogspot.com/-H_Qe6snj9l4/T-g3AE6nI4I/AAAAAAAAAsg/G7Jqjxl2ayY/s1600/19.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="156" src="http://3.bp.blogspot.com/-H_Qe6snj9l4/T-g3AE6nI4I/AAAAAAAAAsg/G7Jqjxl2ayY/s320/19.JPG" width="320" /></a></div>
<div style="text-align: left;">
<br /></div>
<div align="left" class="separator" style="clear: both; text-align: left;">
To fix this we need to load the report programmatically and provide username and password from code behind .</div>
<div align="left" class="separator" style="clear: both; text-align: left;">
Now run the report , it should look like this </div>
<div class="separator" style="clear: both; text-align: left;">
<a href="http://3.bp.blogspot.com/-AbeTwetYesc/T-g3Auk6kNI/AAAAAAAAAsk/U3CPYzYd45c/s1600/20.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="284" src="http://3.bp.blogspot.com/-AbeTwetYesc/T-g3Auk6kNI/AAAAAAAAAsk/U3CPYzYd45c/s320/20.JPG" width="320" /></a></div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div style="text-align: left;">
</div>
</div>
<b>Html markup of default.aspx look like </b><br />
<div class="codeview2">
<pre class="csharpcode"><span class="kwrd"><</span><span class="html">form</span> <span class="attr">id</span><span class="kwrd">="form1"</span> <span class="attr">runat</span><span class="kwrd">="server"</span><span class="kwrd">></span>
<span class="kwrd"><</span><span class="html">div</span><span class="kwrd">></span>
<span class="kwrd"><</span><span class="html">CR:CrystalReportViewer</span> <span class="attr">ID</span><span class="kwrd">="CrystalReportViewer1"</span>
<span class="attr">runat</span><span class="kwrd">="server"</span> <span class="attr">AutoDataBind</span><span class="kwrd">="True"</span>
<span class="attr">Height</span><span class="kwrd">="1039px"</span>
<span class="attr">ReportSourceID</span><span class="kwrd">="CrystalReportSource1"</span>
<span class="attr">Width</span><span class="kwrd">="901px"</span> <span class="kwrd">/></span>
<span class="kwrd"><</span><span class="html">CR:CrystalReportSource</span> <span class="attr">ID</span><span class="kwrd">="CrystalReportSource1"</span>
<span class="attr">runat</span><span class="kwrd">="server"</span><span class="kwrd">></span>
<span class="kwrd"><</span><span class="html">Report</span> <span class="attr">FileName</span><span class="kwrd">="CrystalReport.rpt"</span><span class="kwrd">></span>
<span class="kwrd"></</span><span class="html">Report</span><span class="kwrd">></span>
<span class="kwrd"></</span><span class="html">CR:CrystalReportSource</span><span class="kwrd">></span>
<span class="kwrd"></</span><span class="html">div</span><span class="kwrd">></span>
<span class="kwrd"></</span><span class="html">form</span><span class="kwrd">></span></pre>
</div>
<br /><br />
<strong>using CrystalDecisions.CrystalReports.Engine;<br />using CrystalDecisions.Shared;</strong><br />
<br />
<b>C# code behind</b> <br />
<br />
Write this code in the event you find appropriate , i m writing it in Page_Load , you can write this code in click event of button or in pagePreRender event <br />
The code to provide password programmatically.<br />
<div class="codeview">
<pre class="csharpcode"><span class="kwrd">protected</span> <span class="kwrd">void</span> Page_Load(<span class="kwrd">object</span> sender, EventArgs e)
{
ReportDocument crystalReport = <span class="kwrd">new</span> ReportDocument();
crystalReport.Load(Server.MapPath(<span class="str">"CrystalReport.rpt"</span>));
crystalReport.SetDatabaseLogon
(<span class="str">"amit"</span>, <span class="str">"password"</span>, <span class="str">@"AMIT\SQLEXPRESS"</span>, <span class="str">"TestDB"</span>);
CrystalReportViewer1.ReportSource = crystalReport;
}</pre>
</div>
<br />
<b>VB.NET code behind</b><br />
<div class="codeview2">
<pre class="csharpcode"><span class="kwrd">Protected</span> <span class="kwrd">Sub</span> Page_Load
(<span class="kwrd">ByVal</span> sender <span class="kwrd">As</span> <span class="kwrd">Object</span>, <span class="kwrd">ByVal</span> e <span class="kwrd">As</span> EventArgs)
<span class="kwrd">Dim</span> crystalReport <span class="kwrd">As</span> <span class="kwrd">New</span> ReportDocument()
crystalReport.Load(Server.MapPath(<span class="str">"CrystalReport.rpt"</span>))
crystalReport.SetDatabaseLogon
(<span class="str">"amit"</span>, <span class="str">"password"</span>, <span class="str">"AMIT\SQLEXPRESS"</span>, <span class="str">"TestDB"</span>)
CrystalReportViewer1.ReportSource = crystalReport
<span class="kwrd">End</span> Sub</pre>
</div>
<br />
</div>Unknownnoreply@blogger.com1tag:blogger.com,1999:blog-7129929778341648750.post-60637063208770068282012-06-22T16:35:00.001+05:302012-06-22T16:40:00.113+05:30Windows Forms Tip: Ensure only one instance of your application is running at a time<div dir="ltr" style="text-align: left;" trbidi="on">
In some scenarios, you may wish to ensure that a user can run only one
instance of your application at a time. Besides ensuring that only a single
instance of your application is running, you may also want to bring the
instance already running to the front and restore it, if it is minimized.<br />
<br />
First, to ensure that only one instance of your application is running at a
time, the best method I've found is to create a mutex that is held by the
operating system.
This will put a request to the operating system that a mutex be created if one
does not already exist. Only one mutex can ever be created at a time, so if you
request a new one and it cannot be created, you can safely assume that your
application is already running.<br />
<br />
<br />
<br />
<span style="color: blue; font-size: 10pt;">using </span><span style="font-size: 10pt;">System.Threading<br />
<span style="color: blue;">using</span> System.Runtime.InteropServices;</span><br />
<br />
<span style="color: blue; font-size: 10pt;">public</span><span style="font-size: 10pt;"> <span style="color: blue;">class</span> Form1 : Form<br />
{<br />
[STAThread]<br />
<span style="color: blue;">static</span> <span style="color: blue;">void</span> Main() <br />
{<br />
<span style="color: blue;">bool</span>
createdNew;</span><br />
<br />
<span style="font-size: 10pt;">
Mutex m = <span style="color: blue;">new</span> Mutex(<span style="color: blue;">true</span>,
<span style="color: maroon;">"YourAppName"</span>, <span style="color: blue;">out</span> createdNew);</span><br />
<br />
<span style="color: blue; font-size: 10pt;">
if</span><span style="font-size: 10pt;"> (! createdNew)<br />
{<br />
<span style="color: green;">// app is already running…<br />
</span><span style="color: black;">MessageBox.Show(</span><span style="color: maroon;">"Only one instance of this application is allowed at a time."</span><span style="color: black;">);<br />
</span><span style="color: blue;">return</span><span style="color: black;">;</span><span style="color: green;"><br />
</span><span style="color: black;">}</span></span><br />
<br />
<br />
<br />
<span style="font-size: 10pt;">
Application.Run(<span style="color: blue;">new</span> Form1());</span><br />
<br />
<br />
<br />
<span style="color: green; font-size: 10pt;">
// keep the mutex reference alive until the normal termination of the program<br />
</span><span style="color: black; font-size: 10pt;">
GC.KeepAlive(m);<br />
}<br />
}</span><br />
<br />
The above code will work for the vast majority of your needs. It will also
run under scenarios where your code is executing with less than FullTrust
permissions (see Code Access Security in MSDN for further information).<br />
<br />
If your application can run with Full Trust permissions, we can take this a
step further and find the window of the application instnace already running
and bring it to the front for the user:<br />
<br />
<span style="color: blue; font-size: 10pt;">public</span><span style="font-size: 10pt;"> <span style="color: blue;">class</span> Form1 : Form<br />
{<br />
[STAThread]<br />
<span style="color: blue;">static</span> <span style="color: blue;">void</span> Main() <br />
{<br />
<span style="color: blue;">bool</span>
createdNew;</span><br />
<br />
<span style="font-size: 10pt;">
System.Threading.Mutex m = <span style="color: blue;">new</span>
System.Threading.Mutex(<span style="color: blue;">true</span>, <span style="color: maroon;">"YourAppName"</span>, <span style="color: blue;">out</span>
createdNew);</span><br />
<br />
<span style="color: blue; font-size: 10pt;">
if</span><span style="font-size: 10pt;"> (! createdNew)<br />
{<br />
<span style="color: green;">// see if we can find the other app and Bring it to
front<br />
</span><span style="color: black;">IntPtr hWnd = FindWindow(</span><span style="color: maroon;">"WindowsForms10.Window.8.app3"</span><span style="color: green;">, </span><span style="color: maroon;">"YourAppName"</span><span style="color: black;">);</span></span><br />
<br />
<span style="color: green; font-size: 10pt;">
</span><span style="color: blue; font-size: 10pt;">if</span><span style="color: black; font-size: 10pt;">(hWnd != IntPtr.Zero)</span><span style="color: green; font-size: 10pt;"><br />
</span><span style="color: black; font-size: 10pt;">{</span><span style="color: green; font-size: 10pt;"><br />
</span><span style="color: black; font-size: 10pt;">Form1.WINDOWPLACEMENT
placement = </span><span style="color: blue; font-size: 10pt;">new</span><span style="color: black; font-size: 10pt;"> Form1.WINDOWPLACEMENT();<br />
placement.length = Marshal.SizeOf(placement);</span><br />
<br />
<span style="color: black; font-size: 10pt;">
GetWindowPlacement(hWnd, </span><span style="color: blue; font-size: 10pt;">ref</span><span style="color: green; font-size: 10pt;"> </span><span style="color: black; font-size: 10pt;">placement);</span><br />
<br />
<span style="color: green; font-size: 10pt;">
</span><span style="color: blue; font-size: 10pt;">if</span><span style="color: black; font-size: 10pt;">(placement.showCmd != SW_NORMAL)<br />
{<br />
placement.showCmd = SW_RESTORE;</span><br />
<br />
<span style="color: black; font-size: 10pt;">
SetWindowPlacement(hWnd, </span><span style="color: blue; font-size: 10pt;">ref</span><span style="color: green; font-size: 10pt;"> </span><span style="color: black; font-size: 10pt;">placement);<br />
SetForegroundWindow(hWnd); </span><span style="color: green; font-size: 10pt;"><br />
</span><span style="color: black; font-size: 10pt;"> }<br />
}</span><br />
<br />
<span style="color: green; font-size: 10pt;"> </span><span style="color: blue; font-size: 10pt;">return</span><span style="color: green; font-size: 10pt;">;<br />
</span><span style="color: black; font-size: 10pt;">}</span><br />
<br />
<br />
<br />
<span style="font-size: 10pt;">
Application.Run(<span style="color: blue;">new</span> Form1());</span><br />
<br />
<br />
<br />
<span style="color: green; font-size: 10pt;">
// keep the mutex reference alive until the normal termination of the program<br />
</span><span style="color: black; font-size: 10pt;">
GC.KeepAlive(m);<br />
}</span><br />
<br />
<span style="color: black; font-size: 10pt;"> </span><span style="color: blue; font-size: 10pt;">private</span><span style="color: black; font-size: 10pt;"> </span><span style="color: blue; font-size: 10pt;">const</span><span style="color: black; font-size: 10pt;"> </span><span style="color: blue; font-size: 10pt;">int</span><span style="color: black; font-size: 10pt;"> SW_NORMAL =
1; </span><span style="color: green; font-size: 10pt;">// see WinUser.h for
definitions</span><span style="color: black; font-size: 10pt;"><br />
</span><span style="color: blue; font-size: 10pt;">private</span><span style="color: black; font-size: 10pt;"> </span><span style="color: blue; font-size: 10pt;">const</span><span style="color: black; font-size: 10pt;"> </span><span style="color: blue; font-size: 10pt;">int</span><span style="color: black; font-size: 10pt;"> SW_RESTORE = 9;</span><br />
<br />
<span style="color: black; font-size: 10pt;">
[DllImport(</span><span style="color: maroon; font-size: 10pt;">"User32"</span><span style="color: black; font-size: 10pt;">,EntryPoint=</span><span style="color: maroon; font-size: 10pt;">"FindWindow"</span><span style="color: black; font-size: 10pt;">)]<br />
</span><span style="color: blue; font-size: 10pt;">static</span><span style="color: black; font-size: 10pt;"> </span><span style="color: blue; font-size: 10pt;">extern</span><span style="color: black; font-size: 10pt;"> IntPtr
FindWindow(</span><span style="color: blue; font-size: 10pt;">string</span><span style="color: black; font-size: 10pt;"> className, </span><span style="color: blue; font-size: 10pt;">string</span><span style="color: black; font-size: 10pt;">
windowName);</span><br />
<br />
<span style="color: black; font-size: 10pt;">
[DllImport(</span><span style="color: maroon; font-size: 10pt;">"User32"</span><span style="color: black; font-size: 10pt;">,EntryPoint=</span><span style="color: maroon; font-size: 10pt;">"SendMessage"</span><span style="color: black; font-size: 10pt;">)]<br />
</span><span style="color: blue; font-size: 10pt;">private</span><span style="color: black; font-size: 10pt;"> </span><span style="color: blue; font-size: 10pt;">static</span><span style="color: black; font-size: 10pt;"> </span><span style="color: blue; font-size: 10pt;">extern</span><span style="color: black; font-size: 10pt;"> IntPtr SendMessage(IntPtr hWnd, </span><span style="color: blue; font-size: 10pt;">uint</span><span style="color: black; font-size: 10pt;"> Msg,
IntPtr wParam, IntPtr lParam);</span><br />
<br />
<span style="color: black; font-size: 10pt;">
[DllImport(</span><span style="color: maroon; font-size: 10pt;">"User32"</span><span style="color: black; font-size: 10pt;">,EntryPoint=</span><span style="color: maroon; font-size: 10pt;">"SetForegroundWindow"</span><span style="color: black; font-size: 10pt;">)]<br />
</span><span style="color: blue; font-size: 10pt;">private</span><span style="color: black; font-size: 10pt;"> </span><span style="color: blue; font-size: 10pt;">static</span><span style="color: black; font-size: 10pt;"> </span><span style="color: blue; font-size: 10pt;">extern</span><span style="color: black; font-size: 10pt;"> </span><span style="color: blue; font-size: 10pt;">bool</span><span style="color: black; font-size: 10pt;"> SetForegroundWindow(IntPtr hWnd);</span><br />
<br />
<span style="color: black; font-size: 10pt;">
[DllImport(</span><span style="color: maroon; font-size: 10pt;">"User32"</span><span style="color: black; font-size: 10pt;">,EntryPoint=</span><span style="color: maroon; font-size: 10pt;">"SetWindowPlacement"</span><span style="color: black; font-size: 10pt;">)]<br />
</span><span style="color: blue; font-size: 10pt;">private</span><span style="color: black; font-size: 10pt;"> </span><span style="color: blue; font-size: 10pt;">static</span><span style="color: black; font-size: 10pt;"> </span><span style="color: blue; font-size: 10pt;">extern</span><span style="color: black; font-size: 10pt;"> </span><span style="color: blue; font-size: 10pt;">bool</span><span style="color: black; font-size: 10pt;"> SetWindowPlacement(IntPtr hWnd, [In] </span><span style="color: blue; font-size: 10pt;">ref</span><span style="color: black; font-size: 10pt;"> WINDOWPLACEMENT lpwndpl);</span><br />
<br />
<span style="color: black; font-size: 10pt;">
[DllImport(</span><span style="color: maroon; font-size: 10pt;">"User32"</span><span style="color: black; font-size: 10pt;">,EntryPoint=</span><span style="color: maroon; font-size: 10pt;">"GetWindowPlacement"</span><span style="color: black; font-size: 10pt;">)]<br />
</span><span style="color: blue; font-size: 10pt;">private</span><span style="color: black; font-size: 10pt;"> </span><span style="color: blue; font-size: 10pt;">static</span><span style="color: black; font-size: 10pt;"> </span><span style="color: blue; font-size: 10pt;">extern</span><span style="color: black; font-size: 10pt;"> </span><span style="color: blue; font-size: 10pt;">bool</span><span style="color: black; font-size: 10pt;"> GetWindowPlacement(IntPtr hWnd, [In] </span><span style="color: blue; font-size: 10pt;">ref</span><span style="color: black; font-size: 10pt;"> WINDOWPLACEMENT lpwndpl);</span><br />
<br />
<span style="color: black; font-size: 10pt;"> </span><span style="color: blue; font-size: 10pt;">private</span><span style="color: black; font-size: 10pt;"> </span><span style="color: blue; font-size: 10pt;">struct</span><span style="color: black; font-size: 10pt;"> POINTAPI<br />
{<br />
</span><span style="color: blue; font-size: 10pt;">public</span><span style="color: black; font-size: 10pt;"> </span><span style="color: blue; font-size: 10pt;">int</span><span style="color: black; font-size: 10pt;"> x;<br />
</span><span style="color: blue; font-size: 10pt;">public</span><span style="color: black; font-size: 10pt;"> </span><span style="color: blue; font-size: 10pt;">int</span><span style="color: black; font-size: 10pt;"> y;<br />
}</span><br />
<br />
<span style="color: black; font-size: 10pt;"> </span><span style="color: blue; font-size: 10pt;">private</span><span style="color: black; font-size: 10pt;"> </span><span style="color: blue; font-size: 10pt;">struct</span><span style="color: black; font-size: 10pt;"> RECT<br />
{<br />
</span><span style="color: blue; font-size: 10pt;">public</span><span style="color: black; font-size: 10pt;"> </span><span style="color: blue; font-size: 10pt;">int</span><span style="color: black; font-size: 10pt;"> left;<br />
</span><span style="color: blue; font-size: 10pt;">public</span><span style="color: black; font-size: 10pt;"> </span><span style="color: blue; font-size: 10pt;">int</span><span style="color: black; font-size: 10pt;"> top;<br />
</span><span style="color: blue; font-size: 10pt;">public</span><span style="color: black; font-size: 10pt;"> </span><span style="color: blue; font-size: 10pt;">int</span><span style="color: black; font-size: 10pt;"> right;<br />
</span><span style="color: blue; font-size: 10pt;">public</span><span style="color: black; font-size: 10pt;"> </span><span style="color: blue; font-size: 10pt;">int</span><span style="color: black; font-size: 10pt;"> bottom;<br />
}</span><br />
<br />
<span style="color: black; font-size: 10pt;"> </span><span style="color: blue; font-size: 10pt;">private</span><span style="color: black; font-size: 10pt;"> </span><span style="color: blue; font-size: 10pt;">struct</span><span style="color: black; font-size: 10pt;"> WINDOWPLACEMENT<br />
{<br />
</span><span style="color: blue; font-size: 10pt;">public</span><span style="color: black; font-size: 10pt;"> </span><span style="color: blue; font-size: 10pt;">int</span><span style="color: black; font-size: 10pt;"> length;<br />
</span><span style="color: blue; font-size: 10pt;">public</span><span style="color: black; font-size: 10pt;"> </span><span style="color: blue; font-size: 10pt;">int</span><span style="color: black; font-size: 10pt;"> flags;<br />
</span><span style="color: blue; font-size: 10pt;">public</span><span style="color: black; font-size: 10pt;"> </span><span style="color: blue; font-size: 10pt;">int</span><span style="color: black; font-size: 10pt;"> showCmd;<br />
</span><span style="color: blue; font-size: 10pt;">public</span><span style="color: black; font-size: 10pt;"> POINTAPI ptMinPosition;<br />
</span><span style="color: blue; font-size: 10pt;">public</span><span style="color: black; font-size: 10pt;"> POINTAPI ptMaxPosition;<br />
</span><span style="color: blue; font-size: 10pt;">public</span><span style="color: black; font-size: 10pt;"> RECT rcNormalPosition;<br />
}<br />
}</span><br />
<br />
As you can see, with minimal effort, you can easily add a polished touch to
your application. This might even help you avoid some extra legwork in ensuring
that there are no issues with running multiple instances of your app at the
same time that you might have to address.<br />
<br />
For more information about the Platform Invoke mechanisms to call Win32 API
functions, I recommend that you check out <a href="http://www.amazon.com/exec/obidos/tg/detail/-/078214134X/qid=1090080628/sr=8-4/ref=pd_ka_4/104-0606379-7548728?v=glance&s=books&n=507846"><span style="color: blue;">.NET
Framework Solutions: In Search of the Lost Win32 API</span></a> by John Mueller and
Charles Petzold's seminal classic <a href="http://www.amazon.com/exec/obidos/tg/detail/-/157231995X/qid=1090080691/sr=8-1/ref=sr_8_xs_ap_i1_xgl14/104-0606379-7548728?v=glance&s=books&n=507846"><span style="color: blue;">Programming
Windows</span></a>. <br />
<br />
Until Longhorn comes out and more of the Windows platform becomes managed,
platform invokes and interop will remain a key technology to understand and use
to your advantage to fill the gaps left by the Windows Forms framework.<br />
<br />
<div class="MsoNormal" style="margin: 0in 0in 10pt;">
<br /></div>
<br />
<br />
For C# in VS2008 It’s still pretty short:<br />
<br /><br />
static void Main()<br />
{<br />
bool createdNew;<br />
System.Threading.Mutex m = new System.Threading.Mutex(true, “Your App here”, out createdNew);<br />
<br />
if (!createdNew)<br />
{<br />
MessageBox.Show(“Another instance is already running.”);<br />
return;<br />
}<br />
<br />
{<br />
Application.EnableVisualStyles();<br />
Application.SetCompatibleTextRenderingDefault(false);<br />
Application.Run(new Form1());<br />
} GC.KeepAlive(m); // important!<br />
}</div>Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-7129929778341648750.post-78645732129248757532012-06-20T14:27:00.001+05:302012-06-20T14:27:45.548+05:30MAC Address Using WMI on Internet Explorer<div dir="ltr" style="text-align: left;" trbidi="on">
<div style="font-family: Arial,Helvetica,sans-serif;">
In this little article, i will help you in finding the MAC address from
javascript with the help of WMI Library. The script runs only on IE with
the following limitations
</div>
<ul style="font-family: Arial,Helvetica,sans-serif;">
<li>Works on Internet Explorer only</li>
<li>Internet Explorer security settings should allow creating ActiveX Objects</li>
<li>WMI scripting library is installed on the client machine</li>
</ul>
<div class="heading" style="font-family: Arial,Helvetica,sans-serif;">
Setting IE Security Level</div>
<span style="font-family: Arial,Helvetica,sans-serif;">
First of all you will need to change the security settings of IE, allowing the following two options
</span><br />
<ul style="font-family: Arial,Helvetica,sans-serif;">
<li>Initialize and script ActiveX controls not marked as safe for script -> Set it to enable or prompt</li>
<li>Run ActiveX controls and plugins -> Set it to enable or prompt</li>
</ul>
<span style="font-family: Arial,Helvetica,sans-serif;">
To change these two options, go to </span><b style="font-family: Arial,Helvetica,sans-serif;">Tools</b><span style="font-family: Arial,Helvetica,sans-serif;"> -> </span><b style="font-family: Arial,Helvetica,sans-serif;">Internet Options</b><span style="font-family: Arial,Helvetica,sans-serif;"> -> </span><b style="font-family: Arial,Helvetica,sans-serif;">Security</b><span style="font-family: Arial,Helvetica,sans-serif;"> -> </span><b style="font-family: Arial,Helvetica,sans-serif;">Custom Level</b><span style="font-family: Arial,Helvetica,sans-serif;"> </span><br />
<span style="font-family: Arial,Helvetica,sans-serif;"> </span><span style="font-family: Arial,Helvetica,sans-serif;">
</span><br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://1.bp.blogspot.com/-a8FpIZUQ6Kc/T-GO3tpoCiI/AAAAAAAAAqk/JGSQz_qO8Jw/s1600/internet-options.gif" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="320" src="http://1.bp.blogspot.com/-a8FpIZUQ6Kc/T-GO3tpoCiI/AAAAAAAAAqk/JGSQz_qO8Jw/s320/internet-options.gif" width="254" /></a></div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://2.bp.blogspot.com/-mMN2IAdwFkI/T-GO4ZqZ4RI/AAAAAAAAAqs/mNzWVM2Px2Q/s1600/security-settings.gif" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="320" src="http://2.bp.blogspot.com/-mMN2IAdwFkI/T-GO4ZqZ4RI/AAAAAAAAAqs/mNzWVM2Px2Q/s320/security-settings.gif" width="277" /></a></div>
<br />
<br />
<br />
<br />
<div class="heading" style="font-family: Arial,Helvetica,sans-serif;">
Installing WMI scripting library</div>
<div style="font-family: Arial,Helvetica,sans-serif;">
The next step is to install WMI Library, you can download it for free
from the Microsoft website. WMI Library can be downloaded from<br />
<a href="http://www.microsoft.com/downloads/details.aspx?FamilyID=6430f853-1120-48db-8cc5-f2abdc3ed314&displaylang=en" rel="external, nofollow" target="_blank">http://www.microsoft.com/downloads/details.aspx?FamilyID=6430f853-1120-48db-8cc5-f2abdc3ed314&displaylang=en</a></div>
<div style="font-family: Arial,Helvetica,sans-serif;">
<br /></div>
<div class="heading" style="font-family: Arial,Helvetica,sans-serif;">
<b>What is WMI scripting library?</b></div>
<div style="font-family: Arial,Helvetica,sans-serif;">
The WMI scripting library provides the set of automation objects through
which scripting languages, such as VBScript, JScript, and ActiveState
ActivePerl access the WMI infrastructure. The WMI scripting library is
implemented in a single automation component named wbemdisp.dll that
physically resides in the systemroot\System32\Wbem directory.
(description from microsoft.com)</div>
<div style="font-family: Arial,Helvetica,sans-serif;">
<br /></div>
<div class="heading" style="font-family: Arial,Helvetica,sans-serif;">
<b>SWbemLocator</b></div>
<span style="font-family: Arial,Helvetica,sans-serif;">
At the top of the WMI scripting library object model is the SWbemLocator
object. SWbemLocator is used to establish an authenticated connection
to a WMI namespace, much as the VBScript GetObject function and the WMI
moniker "winmgmts:" are used to establish an authenticated connection to
WMI. However, SWbemLocator is designed to address two specific
scripting scenarios that cannot be performed using GetObject and the WMI
moniker.(description from microsoft.com)</span><br />
<div style="font-family: Arial,Helvetica,sans-serif;">
<br /></div>
<div style="font-family: Arial,Helvetica,sans-serif;">
The whole script is given below, just copy this script and execute in IE only.<span style="background-color: #eeeeee;"> </span></div>
<div style="font-family: Arial,Helvetica,sans-serif;">
<br /></div>
<div class="code">
<pre class="html4strict"><span style="color: #009900;"><span style="color: teal;"><html></span></span>
<span style="color: #009900;"><span style="color: teal;"><head></span></span>
<span style="color: #009900;"><span style="color: teal;"><meta</span> <span style="color: #000066;">http-equiv</span><span style="color: #66cc66;">=</span><span style="color: blue;">"Content-Type"</span> <span style="color: #000066;">content</span><span style="color: #66cc66;">=</span><span style="color: blue;">"text/html; charset=utf-8"</span> <span style="color: #66cc66;">/</span><span style="color: teal;">></span></span>
<span style="color: #009900;"><span style="color: teal;"><title></span></span>Getting MAC Address From Javascript(IE Only)<span style="color: #009900;"><span style="color: teal;"></title></span></span>
<span style="color: #000099; font-weight: bold;"><</span>script language=<span style="color: blue;">"javascript"</span><span style="color: #000099; font-weight: bold;">></span>
<span style="color: black; font-weight: bold;">function</span> showMacAddress<span style="color: #000099; font-weight: bold;">(</span><span style="color: #000099; font-weight: bold;">)</span><span style="color: #000099; font-weight: bold;">{</span>
<span style="color: black; font-weight: bold;">var</span> obj = <span style="color: black; font-weight: bold;">new</span> ActiveXObject<span style="color: #000099; font-weight: bold;">(</span><span style="color: blue;">"WbemScripting.SWbemLocator"</span><span style="color: #000099; font-weight: bold;">)</span>;
<span style="color: black; font-weight: bold;">var</span> s = obj.<span style="color: #006600;">ConnectServer</span><span style="color: #000099; font-weight: bold;">(</span><span style="color: blue;">"."</span><span style="color: #000099; font-weight: bold;">)</span>;
<span style="color: black; font-weight: bold;">var</span> properties = s.<span style="color: #006600;">ExecQuery</span><span style="color: #000099; font-weight: bold;">(</span><span style="color: blue;">"SELECT * FROM Win32_NetworkAdapterConfiguration"</span><span style="color: #000099; font-weight: bold;">)</span>;
<span style="color: black; font-weight: bold;">var</span> e = <span style="color: black; font-weight: bold;">new</span> Enumerator <span style="color: #000099; font-weight: bold;">(</span>properties<span style="color: #000099; font-weight: bold;">)</span>;
<span style="color: black; font-weight: bold;">var</span> output;
output=<span style="color: blue;">'<table border="0" cellPadding="5px" cellSpacing="1px" bgColor="#CCCCCC">'</span>;
output=output + <span style="color: blue;">'<tr bgColor="#EAEAEA"><td>Caption</td><td>MACAddress</td></tr>'</span>;
<span style="color: #000099; font-weight: bold;">while</span><span style="color: #000099; font-weight: bold;">(</span><span style="color: #000099; font-weight: bold;">!</span>e.<span style="color: #006600;">atEnd</span><span style="color: #000099; font-weight: bold;">(</span><span style="color: #000099; font-weight: bold;">)</span><span style="color: #000099; font-weight: bold;">)</span>
<span style="color: #000099; font-weight: bold;">{</span>
e.<span style="color: #006600;">moveNext</span><span style="color: #000099; font-weight: bold;">(</span><span style="color: #000099; font-weight: bold;">)</span>;
<span style="color: black; font-weight: bold;">var</span> p = e.<span style="color: #000099; font-weight: bold;">item</span> <span style="color: #000099; font-weight: bold;">(</span><span style="color: #000099; font-weight: bold;">)</span>;
<span style="color: #000099; font-weight: bold;">if</span><span style="color: #000099; font-weight: bold;">(</span><span style="color: #000099; font-weight: bold;">!</span>p<span style="color: #000099; font-weight: bold;">)</span> <span style="color: #000099; font-weight: bold;">continue</span>;
output=output + <span style="color: blue;">'<tr bgColor="#FFFFFF">'</span>;
output=output + <span style="color: blue;">'<td>'</span> + p.<span style="color: #006600;">Caption</span>; + <span style="color: blue;">'</td>'</span>;
output=output + <span style="color: blue;">'<td>'</span> + p.<span style="color: #006600;">MACAddress</span> + <span style="color: blue;">'</td>'</span>;
output=output + <span style="color: blue;">'</tr>'</span>;
<span style="color: #000099; font-weight: bold;">}</span>
output=output + <span style="color: blue;">'</table>'</span>;
<span style="color: #990099;">document</span>.<span style="color: #006600;">getElementById</span><span style="color: #000099; font-weight: bold;">(</span><span style="color: blue;">"box"</span><span style="color: #000099; font-weight: bold;">)</span>.<span style="color: #006600;">innerHTML</span>=output;
<span style="color: #000099; font-weight: bold;">}</span>
<span style="color: #000099; font-weight: bold;"></</span>script<span style="color: #000099; font-weight: bold;">></span>
<span style="color: #009900;"><span style="color: teal;"></head></span></span>
<span style="color: #009900;"><span style="color: teal;"><body></span></span>
<span style="color: #009900;"><span style="color: teal;"><input</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: blue;">"button"</span> <span style="color: #000066;">value</span><span style="color: #66cc66;">=</span><span style="color: blue;">"Show MAC Address"</span> <span style="color: #000066;">onclick</span><span style="color: #66cc66;">=</span><span style="color: blue;">"showMacAddress()"</span> <span style="color: #66cc66;">/</span><span style="color: teal;">></span></span>
<span style="color: #009900;"><span style="color: teal;"><div</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: blue;">"box"</span><span style="color: teal;">></span></span>
<span style="color: #009900;"><span style="color: teal;"></div></span></span>
<span style="color: #009900;"><span style="color: teal;"></body></span></span>
<span style="color: #009900;"><span style="color: teal;"></html></span></span>
</pre>
</div>
</div>
Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-7129929778341648750.post-14388417276526131882010-05-02T11:55:00.000+05:302010-05-02T11:56:03.912+05:30The Object base class<span style="font-family: arial;">In the .NET Framework, all types are derived from System.Object. That relationship helps establish the common type system used throughout the .NET Framework</span>Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-7129929778341648750.post-6193884003611532512010-05-02T11:46:00.002+05:302010-05-02T11:55:11.638+05:30Using Value Types<span style="font-family: arial;">The simplest types in the .NET Framework, primarily numeric and boolean types, are</span><br /><span style="font-family: arial;">value types. Value types are variables that contain their data directly instead of containing</span><br /><span style="font-family: arial;">a reference to the data stored elsewhere in memory. Instances of value types are</span><br /><span style="font-family: arial;">stored in an area of memory called the stack, where the runtime can create, read,</span><br /><span style="font-family: arial;">update, and remove them quickly with minimal overhead.</span><br /><br /><span style="font-family: arial;">There are three general value types:</span><br /><ul style="font-family: arial;"><li>Built-in types</li><li>User-defined types</li><li>Enumerations</li></ul><span style="font-family: arial;">Each of these types is derived from the System.ValueType base type.</span><br /><span style="font-weight: bold; font-family: arial;"><br /></span>Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-7129929778341648750.post-19021857806631587512010-04-29T15:32:00.002+05:302010-04-29T15:37:44.793+05:30GridView Command<span style="font-weight: bold;">(1)By ID</span><br /><br />CommandArgument='<%# Bind("Pk_CategoryId") %>'<br /><br /><span style="font-weight: bold;">(2)By Data Key</span><br /><br /><br />DataKeyNames="Pk_CategoryId"<br /><br />CommandArgument='<%# Convert.ToString(Container.DataItemIndex) %>'<br /><br /><br /><span style="font-weight: bold;">RowCommand Event </span><br /><br /><br />int id = Convert.ToInt32(e.CommandArgument);<br /> if (id >= Convert.ToInt32(grdAreaVillage.PageSize))<br /> {<br /> id = id - (Convert.ToInt32(grdAreaVillage.PageSize) * Convert.ToInt32(grdAreaVillage.PageIndex));<br /> }<br /> decimal AreaVillageId = Convert.ToDecimal(grdAreaVillage.DataKeys[id]["Pk_CategoryId"]);<br /><br /><br /><br /><span style="font-weight: bold;">Fromat Date</span><br /><br />Text='<%# Convert.ToDateTime(Eval("AnswerDate")).ToString("MMMM d, yyyy") %>'Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-7129929778341648750.post-5607102357573088732010-04-29T15:30:00.001+05:302010-04-29T15:31:55.582+05:30LINQ Compile Query<meta equiv="Content-Type" content="text/html; charset=utf-8"><meta name="ProgId" content="Word.Document"><meta name="Generator" content="Microsoft Word 12"><meta name="Originator" content="Microsoft Word 12"><link rel="File-List" href="file:///E:%5CUsers%5CDhruval%5CAppData%5CLocal%5CTemp%5Cmsohtmlclip1%5C01%5Cclip_filelist.xml"><link rel="themeData" href="file:///E:%5CUsers%5CDhruval%5CAppData%5CLocal%5CTemp%5Cmsohtmlclip1%5C01%5Cclip_themedata.thmx"><link rel="colorSchemeMapping" href="file:///E:%5CUsers%5CDhruval%5CAppData%5CLocal%5CTemp%5Cmsohtmlclip1%5C01%5Cclip_colorschememapping.xml"><!--[if gte mso 9]><xml> <w:worddocument> <w:view>Normal</w:View> <w:zoom>0</w:Zoom> <w:trackmoves/> <w:trackformatting/> <w:punctuationkerning/> <w:validateagainstschemas/> <w:saveifxmlinvalid>false</w:SaveIfXMLInvalid> <w:ignoremixedcontent>false</w:IgnoreMixedContent> <w:alwaysshowplaceholdertext>false</w:AlwaysShowPlaceholderText> <w:donotpromoteqf/> <w:lidthemeother>EN-IN</w:LidThemeOther> <w:lidthemeasian>X-NONE</w:LidThemeAsian> <w:lidthemecomplexscript>X-NONE</w:LidThemeComplexScript> <w:compatibility> <w:breakwrappedtables/> <w:snaptogridincell/> <w:wraptextwithpunct/> <w:useasianbreakrules/> <w:dontgrowautofit/> <w:splitpgbreakandparamark/> <w:dontvertaligncellwithsp/> <w:dontbreakconstrainedforcedtables/> <w:dontvertalignintxbx/> <w:word11kerningpairs/> <w:cachedcolbalance/> </w:Compatibility> <w:browserlevel>MicrosoftInternetExplorer4</w:BrowserLevel> <m:mathpr> <m:mathfont val="Cambria Math"> <m:brkbin val="before"> <m:brkbinsub val="--"> <m:smallfrac val="off"> <m:dispdef/> <m:lmargin val="0"> <m:rmargin val="0"> <m:defjc val="centerGroup"> <m:wrapindent val="1440"> <m:intlim val="subSup"> <m:narylim val="undOvr"> </m:mathPr></w:WordDocument> </xml><![endif]--><!--[if gte mso 9]><xml> <w:latentstyles deflockedstate="false" defunhidewhenused="true" defsemihidden="true" defqformat="false" defpriority="99" latentstylecount="267"> <w:lsdexception locked="false" priority="0" semihidden="false" unhidewhenused="false" qformat="true" name="Normal"> <w:lsdexception locked="false" priority="9" semihidden="false" unhidewhenused="false" qformat="true" name="heading 1"> <w:lsdexception locked="false" priority="9" qformat="true" name="heading 2"> <w:lsdexception locked="false" priority="9" qformat="true" name="heading 3"> <w:lsdexception locked="false" priority="9" qformat="true" name="heading 4"> <w:lsdexception locked="false" priority="9" qformat="true" name="heading 5"> <w:lsdexception locked="false" priority="9" qformat="true" name="heading 6"> <w:lsdexception locked="false" priority="9" qformat="true" name="heading 7"> <w:lsdexception locked="false" priority="9" qformat="true" name="heading 8"> <w:lsdexception locked="false" priority="9" qformat="true" name="heading 9"> <w:lsdexception locked="false" priority="39" name="toc 1"> <w:lsdexception locked="false" priority="39" name="toc 2"> <w:lsdexception locked="false" priority="39" name="toc 3"> <w:lsdexception locked="false" priority="39" name="toc 4"> <w:lsdexception locked="false" priority="39" name="toc 5"> <w:lsdexception locked="false" priority="39" name="toc 6"> <w:lsdexception locked="false" priority="39" name="toc 7"> <w:lsdexception locked="false" priority="39" name="toc 8"> <w:lsdexception locked="false" priority="39" name="toc 9"> <w:lsdexception locked="false" priority="35" qformat="true" name="caption"> <w:lsdexception locked="false" priority="10" semihidden="false" unhidewhenused="false" qformat="true" name="Title"> <w:lsdexception locked="false" priority="1" name="Default Paragraph Font"> <w:lsdexception locked="false" priority="11" semihidden="false" unhidewhenused="false" qformat="true" name="Subtitle"> <w:lsdexception locked="false" priority="22" semihidden="false" unhidewhenused="false" qformat="true" name="Strong"> <w:lsdexception locked="false" priority="20" semihidden="false" unhidewhenused="false" qformat="true" name="Emphasis"> <w:lsdexception locked="false" priority="59" semihidden="false" unhidewhenused="false" name="Table Grid"> <w:lsdexception locked="false" unhidewhenused="false" name="Placeholder Text"> <w:lsdexception locked="false" priority="1" semihidden="false" unhidewhenused="false" qformat="true" name="No Spacing"> <w:lsdexception locked="false" priority="60" semihidden="false" unhidewhenused="false" name="Light Shading"> <w:lsdexception locked="false" priority="61" semihidden="false" unhidewhenused="false" name="Light List"> <w:lsdexception locked="false" priority="62" semihidden="false" unhidewhenused="false" name="Light Grid"> <w:lsdexception locked="false" priority="63" semihidden="false" unhidewhenused="false" name="Medium Shading 1"> <w:lsdexception locked="false" priority="64" semihidden="false" unhidewhenused="false" name="Medium Shading 2"> <w:lsdexception locked="false" priority="65" semihidden="false" unhidewhenused="false" name="Medium List 1"> <w:lsdexception locked="false" priority="66" semihidden="false" unhidewhenused="false" name="Medium List 2"> <w:lsdexception locked="false" priority="67" semihidden="false" unhidewhenused="false" name="Medium Grid 1"> <w:lsdexception locked="false" priority="68" semihidden="false" unhidewhenused="false" name="Medium Grid 2"> <w:lsdexception locked="false" priority="69" semihidden="false" unhidewhenused="false" name="Medium Grid 3"> <w:lsdexception locked="false" priority="70" semihidden="false" unhidewhenused="false" name="Dark List"> <w:lsdexception locked="false" priority="71" semihidden="false" unhidewhenused="false" name="Colorful Shading"> <w:lsdexception locked="false" priority="72" semihidden="false" unhidewhenused="false" name="Colorful List"> <w:lsdexception locked="false" priority="73" semihidden="false" unhidewhenused="false" name="Colorful Grid"> <w:lsdexception locked="false" priority="60" semihidden="false" unhidewhenused="false" name="Light Shading Accent 1"> <w:lsdexception locked="false" priority="61" semihidden="false" unhidewhenused="false" name="Light List Accent 1"> <w:lsdexception locked="false" priority="62" semihidden="false" unhidewhenused="false" name="Light Grid Accent 1"> <w:lsdexception locked="false" priority="63" semihidden="false" unhidewhenused="false" name="Medium Shading 1 Accent 1"> <w:lsdexception locked="false" priority="64" semihidden="false" unhidewhenused="false" name="Medium Shading 2 Accent 1"> <w:lsdexception locked="false" priority="65" semihidden="false" unhidewhenused="false" name="Medium List 1 Accent 1"> <w:lsdexception locked="false" unhidewhenused="false" name="Revision"> <w:lsdexception locked="false" priority="34" semihidden="false" unhidewhenused="false" qformat="true" name="List Paragraph"> <w:lsdexception locked="false" priority="29" semihidden="false" unhidewhenused="false" qformat="true" name="Quote"> <w:lsdexception locked="false" priority="30" semihidden="false" unhidewhenused="false" qformat="true" name="Intense Quote"> <w:lsdexception locked="false" priority="66" semihidden="false" unhidewhenused="false" name="Medium List 2 Accent 1"> <w:lsdexception locked="false" priority="67" semihidden="false" unhidewhenused="false" name="Medium Grid 1 Accent 1"> <w:lsdexception locked="false" priority="68" semihidden="false" unhidewhenused="false" name="Medium Grid 2 Accent 1"> <w:lsdexception locked="false" priority="69" semihidden="false" unhidewhenused="false" name="Medium Grid 3 Accent 1"> <w:lsdexception locked="false" priority="70" semihidden="false" unhidewhenused="false" name="Dark List Accent 1"> <w:lsdexception locked="false" priority="71" semihidden="false" unhidewhenused="false" name="Colorful Shading Accent 1"> <w:lsdexception locked="false" priority="72" semihidden="false" unhidewhenused="false" name="Colorful List Accent 1"> <w:lsdexception locked="false" priority="73" semihidden="false" unhidewhenused="false" name="Colorful Grid Accent 1"> <w:lsdexception locked="false" priority="60" semihidden="false" unhidewhenused="false" name="Light Shading Accent 2"> <w:lsdexception locked="false" priority="61" semihidden="false" unhidewhenused="false" name="Light List Accent 2"> <w:lsdexception locked="false" priority="62" semihidden="false" unhidewhenused="false" name="Light Grid Accent 2"> <w:lsdexception locked="false" priority="63" semihidden="false" unhidewhenused="false" name="Medium Shading 1 Accent 2"> <w:lsdexception locked="false" priority="64" semihidden="false" unhidewhenused="false" name="Medium Shading 2 Accent 2"> <w:lsdexception locked="false" priority="65" semihidden="false" unhidewhenused="false" name="Medium List 1 Accent 2"> <w:lsdexception locked="false" priority="66" semihidden="false" unhidewhenused="false" name="Medium List 2 Accent 2"> <w:lsdexception locked="false" priority="67" semihidden="false" unhidewhenused="false" name="Medium Grid 1 Accent 2"> <w:lsdexception locked="false" priority="68" semihidden="false" unhidewhenused="false" name="Medium Grid 2 Accent 2"> <w:lsdexception locked="false" priority="69" semihidden="false" unhidewhenused="false" name="Medium Grid 3 Accent 2"> <w:lsdexception locked="false" priority="70" semihidden="false" unhidewhenused="false" name="Dark List Accent 2"> <w:lsdexception locked="false" priority="71" semihidden="false" unhidewhenused="false" name="Colorful Shading Accent 2"> <w:lsdexception locked="false" priority="72" semihidden="false" unhidewhenused="false" name="Colorful List Accent 2"> <w:lsdexception locked="false" priority="73" semihidden="false" unhidewhenused="false" name="Colorful Grid Accent 2"> <w:lsdexception locked="false" priority="60" semihidden="false" unhidewhenused="false" name="Light Shading Accent 3"> <w:lsdexception locked="false" priority="61" semihidden="false" unhidewhenused="false" name="Light List Accent 3"> <w:lsdexception locked="false" priority="62" semihidden="false" unhidewhenused="false" name="Light Grid Accent 3"> <w:lsdexception locked="false" priority="63" semihidden="false" unhidewhenused="false" name="Medium Shading 1 Accent 3"> <w:lsdexception locked="false" priority="64" semihidden="false" unhidewhenused="false" name="Medium Shading 2 Accent 3"> <w:lsdexception locked="false" priority="65" semihidden="false" unhidewhenused="false" name="Medium List 1 Accent 3"> <w:lsdexception locked="false" priority="66" semihidden="false" unhidewhenused="false" name="Medium List 2 Accent 3"> <w:lsdexception locked="false" priority="67" semihidden="false" unhidewhenused="false" name="Medium Grid 1 Accent 3"> <w:lsdexception locked="false" priority="68" semihidden="false" unhidewhenused="false" name="Medium Grid 2 Accent 3"> <w:lsdexception locked="false" priority="69" semihidden="false" unhidewhenused="false" name="Medium Grid 3 Accent 3"> <w:lsdexception locked="false" priority="70" semihidden="false" unhidewhenused="false" name="Dark List Accent 3"> <w:lsdexception locked="false" priority="71" semihidden="false" unhidewhenused="false" name="Colorful Shading Accent 3"> <w:lsdexception locked="false" priority="72" semihidden="false" unhidewhenused="false" name="Colorful List Accent 3"> <w:lsdexception locked="false" priority="73" semihidden="false" unhidewhenused="false" name="Colorful Grid Accent 3"> <w:lsdexception locked="false" priority="60" semihidden="false" unhidewhenused="false" name="Light Shading Accent 4"> <w:lsdexception locked="false" priority="61" semihidden="false" unhidewhenused="false" name="Light List Accent 4"> <w:lsdexception locked="false" priority="62" semihidden="false" unhidewhenused="false" name="Light Grid Accent 4"> <w:lsdexception locked="false" priority="63" semihidden="false" unhidewhenused="false" name="Medium Shading 1 Accent 4"> <w:lsdexception locked="false" priority="64" semihidden="false" unhidewhenused="false" name="Medium Shading 2 Accent 4"> <w:lsdexception locked="false" priority="65" semihidden="false" unhidewhenused="false" name="Medium List 1 Accent 4"> <w:lsdexception locked="false" priority="66" semihidden="false" unhidewhenused="false" name="Medium List 2 Accent 4"> <w:lsdexception locked="false" priority="67" semihidden="false" unhidewhenused="false" name="Medium Grid 1 Accent 4"> <w:lsdexception locked="false" priority="68" semihidden="false" unhidewhenused="false" name="Medium Grid 2 Accent 4"> <w:lsdexception locked="false" priority="69" semihidden="false" unhidewhenused="false" name="Medium Grid 3 Accent 4"> <w:lsdexception locked="false" priority="70" semihidden="false" unhidewhenused="false" name="Dark List Accent 4"> <w:lsdexception locked="false" priority="71" semihidden="false" unhidewhenused="false" name="Colorful Shading Accent 4"> <w:lsdexception locked="false" priority="72" semihidden="false" unhidewhenused="false" name="Colorful List Accent 4"> <w:lsdexception locked="false" priority="73" semihidden="false" unhidewhenused="false" name="Colorful Grid Accent 4"> <w:lsdexception locked="false" priority="60" semihidden="false" unhidewhenused="false" name="Light Shading Accent 5"> <w:lsdexception locked="false" priority="61" semihidden="false" unhidewhenused="false" name="Light List Accent 5"> <w:lsdexception locked="false" priority="62" semihidden="false" unhidewhenused="false" name="Light Grid Accent 5"> <w:lsdexception locked="false" priority="63" semihidden="false" unhidewhenused="false" name="Medium Shading 1 Accent 5"> <w:lsdexception locked="false" priority="64" semihidden="false" unhidewhenused="false" name="Medium Shading 2 Accent 5"> <w:lsdexception locked="false" priority="65" semihidden="false" unhidewhenused="false" name="Medium List 1 Accent 5"> <w:lsdexception locked="false" priority="66" semihidden="false" unhidewhenused="false" name="Medium List 2 Accent 5"> <w:lsdexception locked="false" priority="67" semihidden="false" unhidewhenused="false" name="Medium Grid 1 Accent 5"> <w:lsdexception locked="false" priority="68" semihidden="false" unhidewhenused="false" name="Medium Grid 2 Accent 5"> <w:lsdexception locked="false" priority="69" semihidden="false" unhidewhenused="false" name="Medium Grid 3 Accent 5"> <w:lsdexception locked="false" priority="70" semihidden="false" unhidewhenused="false" name="Dark List Accent 5"> <w:lsdexception locked="false" priority="71" semihidden="false" unhidewhenused="false" name="Colorful Shading Accent 5"> <w:lsdexception locked="false" priority="72" semihidden="false" unhidewhenused="false" name="Colorful List Accent 5"> <w:lsdexception locked="false" priority="73" semihidden="false" unhidewhenused="false" name="Colorful Grid Accent 5"> <w:lsdexception locked="false" priority="60" semihidden="false" unhidewhenused="false" name="Light Shading Accent 6"> <w:lsdexception locked="false" priority="61" semihidden="false" unhidewhenused="false" name="Light List Accent 6"> <w:lsdexception locked="false" priority="62" semihidden="false" unhidewhenused="false" name="Light Grid Accent 6"> <w:lsdexception locked="false" priority="63" semihidden="false" unhidewhenused="false" name="Medium Shading 1 Accent 6"> <w:lsdexception locked="false" priority="64" semihidden="false" unhidewhenused="false" name="Medium Shading 2 Accent 6"> <w:lsdexception locked="false" priority="65" semihidden="false" unhidewhenused="false" name="Medium List 1 Accent 6"> <w:lsdexception locked="false" priority="66" semihidden="false" unhidewhenused="false" name="Medium List 2 Accent 6"> <w:lsdexception locked="false" priority="67" semihidden="false" unhidewhenused="false" name="Medium Grid 1 Accent 6"> <w:lsdexception locked="false" priority="68" semihidden="false" unhidewhenused="false" name="Medium Grid 2 Accent 6"> <w:lsdexception locked="false" priority="69" semihidden="false" unhidewhenused="false" name="Medium Grid 3 Accent 6"> <w:lsdexception locked="false" priority="70" semihidden="false" unhidewhenused="false" name="Dark List Accent 6"> <w:lsdexception locked="false" priority="71" semihidden="false" unhidewhenused="false" name="Colorful Shading Accent 6"> <w:lsdexception locked="false" priority="72" semihidden="false" unhidewhenused="false" name="Colorful List Accent 6"> <w:lsdexception locked="false" priority="73" semihidden="false" unhidewhenused="false" name="Colorful Grid Accent 6"> <w:lsdexception locked="false" priority="19" semihidden="false" unhidewhenused="false" qformat="true" name="Subtle Emphasis"> <w:lsdexception locked="false" priority="21" semihidden="false" unhidewhenused="false" qformat="true" name="Intense Emphasis"> <w:lsdexception locked="false" priority="31" semihidden="false" unhidewhenused="false" qformat="true" name="Subtle Reference"> <w:lsdexception locked="false" priority="32" semihidden="false" unhidewhenused="false" qformat="true" name="Intense Reference"> <w:lsdexception locked="false" priority="33" semihidden="false" unhidewhenused="false" qformat="true" name="Book Title"> <w:lsdexception locked="false" priority="37" name="Bibliography"> <w:lsdexception locked="false" priority="39" qformat="true" name="TOC Heading"> </w:LatentStyles> </xml><![endif]--><style> <!-- /* Font Definitions */ @font-face {font-family:"Cambria Math"; panose-1:2 4 5 3 5 4 6 3 2 4; mso-font-charset:0; mso-generic-font-family:roman; mso-font-pitch:variable; mso-font-signature:-1610611985 1107304683 0 0 415 0;} @font-face {font-family:Calibri; panose-1:2 15 5 2 2 2 4 3 2 4; mso-font-charset:0; mso-generic-font-family:swiss; mso-font-pitch:variable; mso-font-signature:-520092929 1073786111 9 0 415 0;} /* Style Definitions */ p.MsoNormal, li.MsoNormal, div.MsoNormal {mso-style-unhide:no; mso-style-qformat:yes; mso-style-parent:""; margin-top:0cm; margin-right:0cm; margin-bottom:10.0pt; margin-left:0cm; line-height:115%; mso-pagination:widow-orphan; font-size:11.0pt; font-family:"Calibri","sans-serif"; mso-ascii-font-family:Calibri; mso-ascii-theme-font:minor-latin; mso-fareast-font-family:Calibri; mso-fareast-theme-font:minor-latin; mso-hansi-font-family:Calibri; mso-hansi-theme-font:minor-latin; mso-bidi-font-family:"Times New Roman"; mso-bidi-theme-font:minor-bidi; mso-fareast-language:EN-US;} .MsoChpDefault {mso-style-type:export-only; mso-default-props:yes; mso-ascii-font-family:Calibri; mso-ascii-theme-font:minor-latin; mso-fareast-font-family:Calibri; mso-fareast-theme-font:minor-latin; mso-hansi-font-family:Calibri; mso-hansi-theme-font:minor-latin; mso-bidi-font-family:"Times New Roman"; mso-bidi-theme-font:minor-bidi; mso-fareast-language:EN-US;} .MsoPapDefault {mso-style-type:export-only; margin-bottom:10.0pt; line-height:115%;} @page Section1 {size:595.3pt 841.9pt; margin:72.0pt 72.0pt 72.0pt 72.0pt; mso-header-margin:35.4pt; mso-footer-margin:35.4pt; mso-paper-source:0;} div.Section1 {page:Section1;} --> </style><!--[if gte mso 10]> <style> /* Style Definitions */ table.MsoNormalTable {mso-style-name:"Table Normal"; mso-tstyle-rowband-size:0; mso-tstyle-colband-size:0; mso-style-noshow:yes; mso-style-priority:99; mso-style-qformat:yes; mso-style-parent:""; mso-padding-alt:0cm 5.4pt 0cm 5.4pt; mso-para-margin-top:0cm; mso-para-margin-right:0cm; mso-para-margin-bottom:10.0pt; mso-para-margin-left:0cm; line-height:115%; mso-pagination:widow-orphan; font-size:11.0pt; font-family:"Calibri","sans-serif"; mso-ascii-font-family:Calibri; mso-ascii-theme-font:minor-latin; mso-fareast-font-family:"Times New Roman"; mso-fareast-theme-font:minor-fareast; mso-hansi-font-family:Calibri; mso-hansi-theme-font:minor-latin; mso-bidi-font-family:"Times New Roman"; mso-bidi-theme-font:minor-bidi;} </style> <![endif]--> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Courier New";"><span style=""> </span><span style="color: blue;">private</span> <span style="color: blue;">static</span> <span style="color: rgb(43, 145, 175);">Func</span><<span style="color: rgb(43, 145, 175);">TestDataContext</span>,<span style=""> </span><span style="color: rgb(43, 145, 175);">IEnumerable</span>><o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Courier New";"><span style=""> </span>ParentRecords =<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Courier New";"><span style=""> </span><span style="color: rgb(43, 145, 175);">CompiledQuery</span>.Compile<<span style="color: rgb(43, 145, 175);">TestDataContext</span>,<span style=""> </span><span style="color: rgb(43, 145, 175);">IEnumerable</span>>((<span style="color: rgb(43, 145, 175);">TestDataContext</span> db) =><o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Courier New";"><span style=""> </span><span style="color: blue;">from</span> m <span style="color: blue;">in</span> db.Tablenames<o:p></o:p></span></p> <p class="MsoNormal"><span style="font-size: 10pt; line-height: 115%; font-family: "Courier New";"><span style=""> </span><span style="color: blue;">select</span> <span style="color: blue;">new</span> { m.CategoryName, m.fk_CategoryId, m.Pk_CategoryId });</span></p> Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-7129929778341648750.post-28433453508484308822010-04-29T08:15:00.001+05:302010-04-29T08:16:58.901+05:30Object Array To DataTable<meta equiv="Content-Type" content="text/html; charset=utf-8"><meta name="ProgId" content="Word.Document"><meta name="Generator" content="Microsoft Word 12"><meta name="Originator" content="Microsoft Word 12"><link rel="File-List" href="file:///E:%5CUsers%5CDhruval%5CAppData%5CLocal%5CTemp%5Cmsohtmlclip1%5C01%5Cclip_filelist.xml"><link rel="themeData" href="file:///E:%5CUsers%5CDhruval%5CAppData%5CLocal%5CTemp%5Cmsohtmlclip1%5C01%5Cclip_themedata.thmx"><link rel="colorSchemeMapping" href="file:///E:%5CUsers%5CDhruval%5CAppData%5CLocal%5CTemp%5Cmsohtmlclip1%5C01%5Cclip_colorschememapping.xml"><!--[if gte mso 9]><xml> <w:worddocument> <w:view>Normal</w:View> <w:zoom>0</w:Zoom> <w:trackmoves/> <w:trackformatting/> <w:punctuationkerning/> <w:validateagainstschemas/> <w:saveifxmlinvalid>false</w:SaveIfXMLInvalid> <w:ignoremixedcontent>false</w:IgnoreMixedContent> <w:alwaysshowplaceholdertext>false</w:AlwaysShowPlaceholderText> <w:donotpromoteqf/> <w:lidthemeother>EN-IN</w:LidThemeOther> <w:lidthemeasian>X-NONE</w:LidThemeAsian> <w:lidthemecomplexscript>X-NONE</w:LidThemeComplexScript> <w:compatibility> <w:breakwrappedtables/> <w:snaptogridincell/> <w:wraptextwithpunct/> <w:useasianbreakrules/> <w:dontgrowautofit/> <w:splitpgbreakandparamark/> <w:dontvertaligncellwithsp/> <w:dontbreakconstrainedforcedtables/> <w:dontvertalignintxbx/> <w:word11kerningpairs/> <w:cachedcolbalance/> </w:Compatibility> <w:browserlevel>MicrosoftInternetExplorer4</w:BrowserLevel> <m:mathpr> <m:mathfont val="Cambria Math"> <m:brkbin val="before"> <m:brkbinsub val="--"> <m:smallfrac val="off"> <m:dispdef/> <m:lmargin val="0"> <m:rmargin val="0"> <m:defjc val="centerGroup"> <m:wrapindent val="1440"> <m:intlim val="subSup"> <m:narylim val="undOvr"> </m:mathPr></w:WordDocument> </xml><![endif]--><!--[if gte mso 9]><xml> <w:latentstyles deflockedstate="false" defunhidewhenused="true" defsemihidden="true" defqformat="false" defpriority="99" latentstylecount="267"> <w:lsdexception locked="false" priority="0" semihidden="false" unhidewhenused="false" qformat="true" name="Normal"> <w:lsdexception locked="false" priority="9" semihidden="false" unhidewhenused="false" qformat="true" name="heading 1"> <w:lsdexception locked="false" priority="9" qformat="true" name="heading 2"> <w:lsdexception locked="false" priority="9" qformat="true" name="heading 3"> <w:lsdexception locked="false" priority="9" qformat="true" name="heading 4"> <w:lsdexception locked="false" priority="9" qformat="true" name="heading 5"> <w:lsdexception locked="false" priority="9" qformat="true" name="heading 6"> <w:lsdexception locked="false" priority="9" qformat="true" name="heading 7"> <w:lsdexception locked="false" priority="9" qformat="true" name="heading 8"> <w:lsdexception locked="false" priority="9" qformat="true" name="heading 9"> <w:lsdexception locked="false" priority="39" name="toc 1"> <w:lsdexception locked="false" priority="39" name="toc 2"> <w:lsdexception locked="false" priority="39" name="toc 3"> <w:lsdexception locked="false" priority="39" name="toc 4"> <w:lsdexception locked="false" priority="39" name="toc 5"> <w:lsdexception locked="false" priority="39" name="toc 6"> <w:lsdexception locked="false" priority="39" name="toc 7"> <w:lsdexception locked="false" priority="39" name="toc 8"> <w:lsdexception locked="false" priority="39" name="toc 9"> <w:lsdexception locked="false" priority="35" qformat="true" name="caption"> <w:lsdexception locked="false" priority="10" semihidden="false" unhidewhenused="false" qformat="true" name="Title"> <w:lsdexception locked="false" priority="1" name="Default Paragraph Font"> <w:lsdexception locked="false" priority="11" semihidden="false" unhidewhenused="false" qformat="true" name="Subtitle"> <w:lsdexception locked="false" priority="22" semihidden="false" unhidewhenused="false" qformat="true" name="Strong"> <w:lsdexception locked="false" priority="20" semihidden="false" unhidewhenused="false" qformat="true" name="Emphasis"> <w:lsdexception locked="false" priority="59" semihidden="false" unhidewhenused="false" name="Table Grid"> <w:lsdexception locked="false" unhidewhenused="false" name="Placeholder Text"> <w:lsdexception locked="false" priority="1" semihidden="false" unhidewhenused="false" qformat="true" name="No Spacing"> <w:lsdexception locked="false" priority="60" semihidden="false" unhidewhenused="false" name="Light Shading"> <w:lsdexception locked="false" priority="61" semihidden="false" unhidewhenused="false" name="Light List"> <w:lsdexception locked="false" priority="62" semihidden="false" unhidewhenused="false" name="Light Grid"> <w:lsdexception locked="false" priority="63" semihidden="false" unhidewhenused="false" name="Medium Shading 1"> <w:lsdexception locked="false" priority="64" semihidden="false" unhidewhenused="false" name="Medium Shading 2"> <w:lsdexception locked="false" priority="65" semihidden="false" unhidewhenused="false" name="Medium List 1"> <w:lsdexception locked="false" priority="66" semihidden="false" unhidewhenused="false" name="Medium List 2"> <w:lsdexception locked="false" priority="67" semihidden="false" unhidewhenused="false" name="Medium Grid 1"> <w:lsdexception locked="false" priority="68" semihidden="false" unhidewhenused="false" name="Medium Grid 2"> <w:lsdexception locked="false" priority="69" semihidden="false" unhidewhenused="false" name="Medium Grid 3"> <w:lsdexception locked="false" priority="70" semihidden="false" unhidewhenused="false" name="Dark List"> <w:lsdexception locked="false" priority="71" semihidden="false" unhidewhenused="false" name="Colorful Shading"> <w:lsdexception locked="false" priority="72" semihidden="false" unhidewhenused="false" name="Colorful List"> <w:lsdexception locked="false" priority="73" semihidden="false" unhidewhenused="false" name="Colorful Grid"> <w:lsdexception locked="false" priority="60" semihidden="false" unhidewhenused="false" name="Light Shading Accent 1"> <w:lsdexception locked="false" priority="61" semihidden="false" unhidewhenused="false" name="Light List Accent 1"> <w:lsdexception locked="false" priority="62" semihidden="false" unhidewhenused="false" name="Light Grid Accent 1"> <w:lsdexception locked="false" priority="63" semihidden="false" unhidewhenused="false" name="Medium Shading 1 Accent 1"> <w:lsdexception locked="false" priority="64" semihidden="false" unhidewhenused="false" name="Medium Shading 2 Accent 1"> <w:lsdexception locked="false" priority="65" semihidden="false" unhidewhenused="false" name="Medium List 1 Accent 1"> <w:lsdexception locked="false" unhidewhenused="false" name="Revision"> <w:lsdexception locked="false" priority="34" semihidden="false" unhidewhenused="false" qformat="true" name="List Paragraph"> <w:lsdexception locked="false" priority="29" semihidden="false" unhidewhenused="false" qformat="true" name="Quote"> <w:lsdexception locked="false" priority="30" semihidden="false" unhidewhenused="false" qformat="true" name="Intense Quote"> <w:lsdexception locked="false" priority="66" semihidden="false" unhidewhenused="false" name="Medium List 2 Accent 1"> <w:lsdexception locked="false" priority="67" semihidden="false" unhidewhenused="false" name="Medium Grid 1 Accent 1"> <w:lsdexception locked="false" priority="68" semihidden="false" unhidewhenused="false" name="Medium Grid 2 Accent 1"> <w:lsdexception locked="false" priority="69" semihidden="false" unhidewhenused="false" name="Medium Grid 3 Accent 1"> <w:lsdexception locked="false" priority="70" semihidden="false" unhidewhenused="false" name="Dark List Accent 1"> <w:lsdexception locked="false" priority="71" semihidden="false" unhidewhenused="false" name="Colorful Shading Accent 1"> <w:lsdexception locked="false" priority="72" semihidden="false" unhidewhenused="false" name="Colorful List Accent 1"> <w:lsdexception locked="false" priority="73" semihidden="false" unhidewhenused="false" name="Colorful Grid Accent 1"> <w:lsdexception locked="false" priority="60" semihidden="false" unhidewhenused="false" name="Light Shading Accent 2"> <w:lsdexception locked="false" priority="61" semihidden="false" unhidewhenused="false" name="Light List Accent 2"> <w:lsdexception locked="false" priority="62" semihidden="false" unhidewhenused="false" name="Light Grid Accent 2"> <w:lsdexception locked="false" priority="63" semihidden="false" unhidewhenused="false" name="Medium Shading 1 Accent 2"> <w:lsdexception locked="false" priority="64" semihidden="false" unhidewhenused="false" name="Medium Shading 2 Accent 2"> <w:lsdexception locked="false" priority="65" semihidden="false" unhidewhenused="false" name="Medium List 1 Accent 2"> <w:lsdexception locked="false" priority="66" semihidden="false" unhidewhenused="false" name="Medium List 2 Accent 2"> <w:lsdexception locked="false" priority="67" semihidden="false" unhidewhenused="false" name="Medium Grid 1 Accent 2"> <w:lsdexception locked="false" priority="68" semihidden="false" unhidewhenused="false" name="Medium Grid 2 Accent 2"> <w:lsdexception locked="false" priority="69" semihidden="false" unhidewhenused="false" name="Medium Grid 3 Accent 2"> <w:lsdexception locked="false" priority="70" semihidden="false" unhidewhenused="false" name="Dark List Accent 2"> <w:lsdexception locked="false" priority="71" semihidden="false" unhidewhenused="false" name="Colorful Shading Accent 2"> <w:lsdexception locked="false" priority="72" semihidden="false" unhidewhenused="false" name="Colorful List Accent 2"> <w:lsdexception locked="false" priority="73" semihidden="false" unhidewhenused="false" name="Colorful Grid Accent 2"> <w:lsdexception locked="false" priority="60" semihidden="false" unhidewhenused="false" name="Light Shading Accent 3"> <w:lsdexception locked="false" priority="61" semihidden="false" unhidewhenused="false" name="Light List Accent 3"> <w:lsdexception locked="false" priority="62" semihidden="false" unhidewhenused="false" name="Light Grid Accent 3"> <w:lsdexception locked="false" priority="63" semihidden="false" unhidewhenused="false" name="Medium Shading 1 Accent 3"> <w:lsdexception locked="false" priority="64" semihidden="false" unhidewhenused="false" name="Medium Shading 2 Accent 3"> <w:lsdexception locked="false" priority="65" semihidden="false" unhidewhenused="false" name="Medium List 1 Accent 3"> <w:lsdexception locked="false" priority="66" semihidden="false" unhidewhenused="false" name="Medium List 2 Accent 3"> <w:lsdexception locked="false" priority="67" semihidden="false" unhidewhenused="false" name="Medium Grid 1 Accent 3"> <w:lsdexception locked="false" priority="68" semihidden="false" unhidewhenused="false" name="Medium Grid 2 Accent 3"> <w:lsdexception locked="false" priority="69" semihidden="false" unhidewhenused="false" name="Medium Grid 3 Accent 3"> <w:lsdexception locked="false" priority="70" semihidden="false" unhidewhenused="false" name="Dark List Accent 3"> <w:lsdexception locked="false" priority="71" semihidden="false" unhidewhenused="false" name="Colorful Shading Accent 3"> <w:lsdexception locked="false" priority="72" semihidden="false" unhidewhenused="false" name="Colorful List Accent 3"> <w:lsdexception locked="false" priority="73" semihidden="false" unhidewhenused="false" name="Colorful Grid Accent 3"> <w:lsdexception locked="false" priority="60" semihidden="false" unhidewhenused="false" name="Light Shading Accent 4"> <w:lsdexception locked="false" priority="61" semihidden="false" unhidewhenused="false" name="Light List Accent 4"> <w:lsdexception locked="false" priority="62" semihidden="false" unhidewhenused="false" name="Light Grid Accent 4"> <w:lsdexception locked="false" priority="63" semihidden="false" unhidewhenused="false" name="Medium Shading 1 Accent 4"> <w:lsdexception locked="false" priority="64" semihidden="false" unhidewhenused="false" name="Medium Shading 2 Accent 4"> <w:lsdexception locked="false" priority="65" semihidden="false" unhidewhenused="false" name="Medium List 1 Accent 4"> <w:lsdexception locked="false" priority="66" semihidden="false" unhidewhenused="false" name="Medium List 2 Accent 4"> <w:lsdexception locked="false" priority="67" semihidden="false" unhidewhenused="false" name="Medium Grid 1 Accent 4"> <w:lsdexception locked="false" priority="68" semihidden="false" unhidewhenused="false" name="Medium Grid 2 Accent 4"> <w:lsdexception locked="false" priority="69" semihidden="false" unhidewhenused="false" name="Medium Grid 3 Accent 4"> <w:lsdexception locked="false" priority="70" semihidden="false" unhidewhenused="false" name="Dark List Accent 4"> <w:lsdexception locked="false" priority="71" semihidden="false" unhidewhenused="false" name="Colorful Shading Accent 4"> <w:lsdexception locked="false" priority="72" semihidden="false" unhidewhenused="false" name="Colorful List Accent 4"> <w:lsdexception locked="false" priority="73" semihidden="false" unhidewhenused="false" name="Colorful Grid Accent 4"> <w:lsdexception locked="false" priority="60" semihidden="false" unhidewhenused="false" name="Light Shading Accent 5"> <w:lsdexception locked="false" priority="61" semihidden="false" unhidewhenused="false" name="Light List Accent 5"> <w:lsdexception locked="false" priority="62" semihidden="false" unhidewhenused="false" name="Light Grid Accent 5"> <w:lsdexception locked="false" priority="63" semihidden="false" unhidewhenused="false" name="Medium Shading 1 Accent 5"> <w:lsdexception locked="false" priority="64" semihidden="false" unhidewhenused="false" name="Medium Shading 2 Accent 5"> <w:lsdexception locked="false" priority="65" semihidden="false" unhidewhenused="false" name="Medium List 1 Accent 5"> <w:lsdexception locked="false" priority="66" semihidden="false" unhidewhenused="false" name="Medium List 2 Accent 5"> <w:lsdexception locked="false" priority="67" semihidden="false" unhidewhenused="false" name="Medium Grid 1 Accent 5"> <w:lsdexception locked="false" priority="68" semihidden="false" unhidewhenused="false" name="Medium Grid 2 Accent 5"> <w:lsdexception locked="false" priority="69" semihidden="false" unhidewhenused="false" name="Medium Grid 3 Accent 5"> <w:lsdexception locked="false" priority="70" semihidden="false" unhidewhenused="false" name="Dark List Accent 5"> <w:lsdexception locked="false" priority="71" semihidden="false" unhidewhenused="false" name="Colorful Shading Accent 5"> <w:lsdexception locked="false" priority="72" semihidden="false" unhidewhenused="false" name="Colorful List Accent 5"> <w:lsdexception locked="false" priority="73" semihidden="false" unhidewhenused="false" name="Colorful Grid Accent 5"> <w:lsdexception locked="false" priority="60" semihidden="false" unhidewhenused="false" name="Light Shading Accent 6"> <w:lsdexception locked="false" priority="61" semihidden="false" unhidewhenused="false" name="Light List Accent 6"> <w:lsdexception locked="false" priority="62" semihidden="false" unhidewhenused="false" name="Light Grid Accent 6"> <w:lsdexception locked="false" priority="63" semihidden="false" unhidewhenused="false" name="Medium Shading 1 Accent 6"> <w:lsdexception locked="false" priority="64" semihidden="false" unhidewhenused="false" name="Medium Shading 2 Accent 6"> <w:lsdexception locked="false" priority="65" semihidden="false" unhidewhenused="false" name="Medium List 1 Accent 6"> <w:lsdexception locked="false" priority="66" semihidden="false" unhidewhenused="false" name="Medium List 2 Accent 6"> <w:lsdexception locked="false" priority="67" semihidden="false" unhidewhenused="false" name="Medium Grid 1 Accent 6"> <w:lsdexception locked="false" priority="68" semihidden="false" unhidewhenused="false" name="Medium Grid 2 Accent 6"> <w:lsdexception locked="false" priority="69" semihidden="false" unhidewhenused="false" name="Medium Grid 3 Accent 6"> <w:lsdexception locked="false" priority="70" semihidden="false" unhidewhenused="false" name="Dark List Accent 6"> <w:lsdexception locked="false" priority="71" semihidden="false" unhidewhenused="false" name="Colorful Shading Accent 6"> <w:lsdexception locked="false" priority="72" semihidden="false" unhidewhenused="false" name="Colorful List Accent 6"> <w:lsdexception locked="false" priority="73" semihidden="false" unhidewhenused="false" name="Colorful Grid Accent 6"> <w:lsdexception locked="false" priority="19" semihidden="false" unhidewhenused="false" qformat="true" name="Subtle Emphasis"> <w:lsdexception locked="false" priority="21" semihidden="false" unhidewhenused="false" qformat="true" name="Intense Emphasis"> <w:lsdexception locked="false" priority="31" semihidden="false" unhidewhenused="false" qformat="true" name="Subtle Reference"> <w:lsdexception locked="false" priority="32" semihidden="false" unhidewhenused="false" qformat="true" name="Intense Reference"> <w:lsdexception locked="false" priority="33" semihidden="false" unhidewhenused="false" qformat="true" name="Book Title"> <w:lsdexception locked="false" priority="37" name="Bibliography"> <w:lsdexception locked="false" priority="39" qformat="true" name="TOC Heading"> </w:LatentStyles> </xml><![endif]--><style> <!-- /* Font Definitions */ @font-face {font-family:"Cambria Math"; panose-1:2 4 5 3 5 4 6 3 2 4; mso-font-charset:1; mso-generic-font-family:roman; mso-font-format:other; mso-font-pitch:variable; mso-font-signature:0 0 0 0 0 0;} @font-face {font-family:Calibri; panose-1:2 15 5 2 2 2 4 3 2 4; mso-font-charset:0; mso-generic-font-family:swiss; mso-font-pitch:variable; mso-font-signature:-520092929 1073786111 9 0 415 0;} /* Style Definitions */ p.MsoNormal, li.MsoNormal, div.MsoNormal {mso-style-unhide:no; mso-style-qformat:yes; mso-style-parent:""; margin-top:0cm; margin-right:0cm; margin-bottom:10.0pt; margin-left:0cm; line-height:115%; mso-pagination:widow-orphan; font-size:11.0pt; font-family:"Calibri","sans-serif"; mso-ascii-font-family:Calibri; mso-ascii-theme-font:minor-latin; mso-fareast-font-family:Calibri; mso-fareast-theme-font:minor-latin; mso-hansi-font-family:Calibri; mso-hansi-theme-font:minor-latin; mso-bidi-font-family:"Times New Roman"; mso-bidi-theme-font:minor-bidi; mso-fareast-language:EN-US;} .MsoChpDefault {mso-style-type:export-only; mso-default-props:yes; mso-ascii-font-family:Calibri; mso-ascii-theme-font:minor-latin; mso-fareast-font-family:Calibri; mso-fareast-theme-font:minor-latin; mso-hansi-font-family:Calibri; mso-hansi-theme-font:minor-latin; mso-bidi-font-family:"Times New Roman"; mso-bidi-theme-font:minor-bidi; mso-fareast-language:EN-US;} .MsoPapDefault {mso-style-type:export-only; margin-bottom:10.0pt; line-height:115%;} @page Section1 {size:595.3pt 841.9pt; margin:72.0pt 72.0pt 72.0pt 72.0pt; mso-header-margin:35.4pt; mso-footer-margin:35.4pt; mso-paper-source:0;} div.Section1 {page:Section1;} --> </style><!--[if gte mso 10]> <style> /* Style Definitions */ table.MsoNormalTable {mso-style-name:"Table Normal"; mso-tstyle-rowband-size:0; mso-tstyle-colband-size:0; mso-style-noshow:yes; mso-style-priority:99; mso-style-qformat:yes; mso-style-parent:""; mso-padding-alt:0cm 5.4pt 0cm 5.4pt; mso-para-margin-top:0cm; mso-para-margin-right:0cm; mso-para-margin-bottom:10.0pt; mso-para-margin-left:0cm; line-height:115%; mso-pagination:widow-orphan; font-size:11.0pt; font-family:"Calibri","sans-serif"; mso-ascii-font-family:Calibri; mso-ascii-theme-font:minor-latin; mso-fareast-font-family:"Times New Roman"; mso-fareast-theme-font:minor-fareast; mso-hansi-font-family:Calibri; mso-hansi-theme-font:minor-latin; mso-bidi-font-family:"Times New Roman"; mso-bidi-theme-font:minor-bidi;} </style> <![endif]--> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Courier New"; color: blue;">#region</span><span style="font-size: 10pt; font-family: "Courier New";"> Object Array to DataTable<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Courier New";"><o:p> </o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Courier New";"><span style=""> </span><span style="color: gray;"><o:p></o:p></span></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Courier New";"><span style=""> </span><span style="color: gray;">///</span><span style="color: green;"> Method to Convert Datatable from object Array.<o:p></o:p></span></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Courier New";"><span style=""> </span><span style="color: gray;"><o:p></o:p></span></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Courier New";"><span style=""> </span><span style="color: gray;"><o:p></o:p></span></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Courier New";"><span style=""> </span><span style="color: blue;">public</span> <span style="color: blue;">static</span> DataTable ToDatatable(<span style="color: blue;">this</span> <span style="color: rgb(43, 145, 175);">Object</span>[] array)<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Courier New";"><span style=""> </span>{<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Courier New";"><o:p> </o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Courier New";"><span style=""> </span><span style="color: rgb(43, 145, 175);">PropertyInfo</span>[] properties = array.GetType().GetElementType().GetProperties();<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Courier New";"><span style=""> </span>DataTable dt = CreateDataTable(properties);<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Courier New";"><span style=""> </span><span style="color: blue;">if</span> (array.Length != 0)<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Courier New";"><span style=""> </span>{<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Courier New";"><span style=""> </span><span style="color: blue;">foreach</span> (<span style="color: blue;">object</span> o <span style="color: blue;">in</span> array)<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Courier New";"><span style=""> </span>FillData(properties, dt, o);<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Courier New";"><span style=""> </span>}<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Courier New";"><span style=""> </span><span style="color: blue;">return</span> dt;<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Courier New";"><span style=""> </span>}<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Courier New";"><o:p> </o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Courier New";"><span style="">
<br /></span></span></p><p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;">
<br /></p><p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;">
<br /><span style="font-size: 10pt; font-family: "Courier New";"><span style=""></span><span style="color: gray;"><o:p></o:p></span></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Courier New";"><span style=""> </span><span style="color: gray;">///</span><span style="color: green;"> Method To Create total column of datatable.<o:p></o:p></span></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Courier New";"><span style=""> </span><span style="color: gray;"><o:p></o:p></span></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Courier New";"><span style=""> </span><span style="color: blue;">private</span> <span style="color: blue;">static</span> DataTable CreateDataTable(<span style="color: rgb(43, 145, 175);">PropertyInfo</span>[] properties)<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Courier New";"><span style=""> </span>{<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Courier New";"><span style=""> </span>DataTable dt = <span style="color: blue;">new</span> DataTable();<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Courier New";"><span style=""> </span>DataColumn dc = <span style="color: blue;">null</span>;<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Courier New";"><span style=""> </span><span style="color: blue;">foreach</span> (<span style="color: rgb(43, 145, 175);">PropertyInfo</span> pi <span style="color: blue;">in</span> properties)<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Courier New";"><span style=""> </span>{<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Courier New";"><span style=""> </span>dc = <span style="color: blue;">new</span> DataColumn();<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Courier New";"><span style=""> </span><span style=""> </span>dc.ColumnName = pi.Name;<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Courier New";"><span style=""> </span><span style="color: green;">//dc.DataType = pi.PropertyType;<o:p></o:p></span></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Courier New";"><span style=""> </span>dt.Columns.Add(dc);<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Courier New";"><span style=""> </span>}<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Courier New";"><span style=""> </span><span style="color: blue;">return</span> dt;<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Courier New";"><span style=""> </span>}<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Courier New";"><o:p> </o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Courier New";"><span style="">
<br /></span></span></p><p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;">
<br /><span style="font-size: 10pt; font-family: "Courier New";"><span style=""></span><span style="color: gray;"><o:p></o:p></span></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Courier New";"><span style=""> </span><span style="color: gray;">///</span><span style="color: green;"> Method for Fill data in DataTable.<o:p></o:p></span></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Courier New";"><span style=""> </span></span><span style="font-size: 10pt; font-family: "Courier New"; color: gray;"><o:p>
<br /></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Courier New";"><span style=""> </span><span style="color: blue;">private</span> <span style="color: blue;">static</span> <span style="color: blue;">void</span> FillData(<span style="color: rgb(43, 145, 175);">PropertyInfo</span>[] properties, DataTable dt, <span style="color: rgb(43, 145, 175);">Object</span> o)<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Courier New";"><span style=""> </span>{<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Courier New";"><span style=""> </span>DataRow dr = dt.NewRow();<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Courier New";"><span style=""> </span><span style="color: blue;">foreach</span> (<span style="color: rgb(43, 145, 175);">PropertyInfo</span> pi <span style="color: blue;">in</span> properties)<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Courier New";"><span style=""> </span>{<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Courier New";"><span style=""> </span>dr[pi.Name] = pi.GetValue(o, <span style="color: blue;">null</span>);<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Courier New";"><span style=""> </span>}<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Courier New";"><span style=""> </span>dt.Rows.Add(dr);<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Courier New";"><span style=""> </span>}<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Courier New";"><o:p> </o:p></span></p> <p class="MsoNormal"><span style="font-size: 10pt; line-height: 115%; font-family: "Courier New"; color: blue;"><span style=""> </span>#endregion</span></p> Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-7129929778341648750.post-76263938531382286762010-04-29T08:12:00.000+05:302010-04-29T08:14:31.320+05:30List To DataTable<meta equiv="Content-Type" content="text/html; charset=utf-8"><meta name="ProgId" content="Word.Document"><meta name="Generator" content="Microsoft Word 12"><meta name="Originator" content="Microsoft Word 12"><link rel="File-List" href="file:///E:%5CUsers%5CDhruval%5CAppData%5CLocal%5CTemp%5Cmsohtmlclip1%5C01%5Cclip_filelist.xml"><link rel="themeData" href="file:///E:%5CUsers%5CDhruval%5CAppData%5CLocal%5CTemp%5Cmsohtmlclip1%5C01%5Cclip_themedata.thmx"><link rel="colorSchemeMapping" href="file:///E:%5CUsers%5CDhruval%5CAppData%5CLocal%5CTemp%5Cmsohtmlclip1%5C01%5Cclip_colorschememapping.xml"><!--[if gte mso 9]><xml> <w:worddocument> <w:view>Normal</w:View> <w:zoom>0</w:Zoom> <w:trackmoves/> <w:trackformatting/> <w:punctuationkerning/> <w:validateagainstschemas/> <w:saveifxmlinvalid>false</w:SaveIfXMLInvalid> <w:ignoremixedcontent>false</w:IgnoreMixedContent> <w:alwaysshowplaceholdertext>false</w:AlwaysShowPlaceholderText> <w:donotpromoteqf/> <w:lidthemeother>EN-IN</w:LidThemeOther> <w:lidthemeasian>X-NONE</w:LidThemeAsian> <w:lidthemecomplexscript>X-NONE</w:LidThemeComplexScript> <w:compatibility> <w:breakwrappedtables/> <w:snaptogridincell/> <w:wraptextwithpunct/> <w:useasianbreakrules/> <w:dontgrowautofit/> <w:splitpgbreakandparamark/> <w:dontvertaligncellwithsp/> <w:dontbreakconstrainedforcedtables/> <w:dontvertalignintxbx/> <w:word11kerningpairs/> <w:cachedcolbalance/> </w:Compatibility> <w:browserlevel>MicrosoftInternetExplorer4</w:BrowserLevel> <m:mathpr> <m:mathfont val="Cambria Math"> <m:brkbin val="before"> <m:brkbinsub val="--"> <m:smallfrac val="off"> <m:dispdef/> <m:lmargin val="0"> <m:rmargin val="0"> <m:defjc val="centerGroup"> <m:wrapindent val="1440"> <m:intlim val="subSup"> <m:narylim val="undOvr"> </m:mathPr></w:WordDocument> </xml><![endif]--><!--[if gte mso 9]><xml> <w:latentstyles deflockedstate="false" defunhidewhenused="true" defsemihidden="true" defqformat="false" defpriority="99" latentstylecount="267"> <w:lsdexception locked="false" priority="0" semihidden="false" unhidewhenused="false" qformat="true" name="Normal"> <w:lsdexception locked="false" priority="9" semihidden="false" unhidewhenused="false" qformat="true" name="heading 1"> <w:lsdexception locked="false" priority="9" qformat="true" name="heading 2"> <w:lsdexception locked="false" priority="9" qformat="true" name="heading 3"> <w:lsdexception locked="false" priority="9" qformat="true" name="heading 4"> <w:lsdexception locked="false" priority="9" qformat="true" name="heading 5"> <w:lsdexception locked="false" priority="9" qformat="true" name="heading 6"> <w:lsdexception locked="false" priority="9" qformat="true" name="heading 7"> <w:lsdexception locked="false" priority="9" qformat="true" name="heading 8"> <w:lsdexception locked="false" priority="9" qformat="true" name="heading 9"> <w:lsdexception locked="false" priority="39" name="toc 1"> <w:lsdexception locked="false" priority="39" name="toc 2"> <w:lsdexception locked="false" priority="39" name="toc 3"> <w:lsdexception locked="false" priority="39" name="toc 4"> <w:lsdexception locked="false" priority="39" name="toc 5"> <w:lsdexception locked="false" priority="39" name="toc 6"> <w:lsdexception locked="false" priority="39" name="toc 7"> <w:lsdexception locked="false" priority="39" name="toc 8"> <w:lsdexception locked="false" priority="39" name="toc 9"> <w:lsdexception locked="false" priority="35" qformat="true" name="caption"> <w:lsdexception locked="false" priority="10" semihidden="false" unhidewhenused="false" qformat="true" name="Title"> <w:lsdexception locked="false" priority="1" name="Default Paragraph Font"> <w:lsdexception locked="false" priority="11" semihidden="false" unhidewhenused="false" qformat="true" name="Subtitle"> <w:lsdexception locked="false" priority="22" semihidden="false" unhidewhenused="false" qformat="true" name="Strong"> <w:lsdexception locked="false" priority="20" semihidden="false" unhidewhenused="false" qformat="true" name="Emphasis"> <w:lsdexception locked="false" priority="59" semihidden="false" unhidewhenused="false" name="Table Grid"> <w:lsdexception locked="false" unhidewhenused="false" name="Placeholder Text"> <w:lsdexception locked="false" priority="1" semihidden="false" unhidewhenused="false" qformat="true" name="No Spacing"> <w:lsdexception locked="false" priority="60" semihidden="false" unhidewhenused="false" name="Light Shading"> <w:lsdexception locked="false" priority="61" semihidden="false" unhidewhenused="false" name="Light List"> <w:lsdexception locked="false" priority="62" semihidden="false" unhidewhenused="false" name="Light Grid"> <w:lsdexception locked="false" priority="63" semihidden="false" unhidewhenused="false" name="Medium Shading 1"> <w:lsdexception locked="false" priority="64" semihidden="false" unhidewhenused="false" name="Medium Shading 2"> <w:lsdexception locked="false" priority="65" semihidden="false" unhidewhenused="false" name="Medium List 1"> <w:lsdexception locked="false" priority="66" semihidden="false" unhidewhenused="false" name="Medium List 2"> <w:lsdexception locked="false" priority="67" semihidden="false" unhidewhenused="false" name="Medium Grid 1"> <w:lsdexception locked="false" priority="68" semihidden="false" unhidewhenused="false" name="Medium Grid 2"> <w:lsdexception locked="false" priority="69" semihidden="false" unhidewhenused="false" name="Medium Grid 3"> <w:lsdexception locked="false" priority="70" semihidden="false" unhidewhenused="false" name="Dark List"> <w:lsdexception locked="false" priority="71" semihidden="false" unhidewhenused="false" name="Colorful Shading"> <w:lsdexception locked="false" priority="72" semihidden="false" unhidewhenused="false" name="Colorful List"> <w:lsdexception locked="false" priority="73" semihidden="false" unhidewhenused="false" name="Colorful Grid"> <w:lsdexception locked="false" priority="60" semihidden="false" unhidewhenused="false" name="Light Shading Accent 1"> <w:lsdexception locked="false" priority="61" semihidden="false" unhidewhenused="false" name="Light List Accent 1"> <w:lsdexception locked="false" priority="62" semihidden="false" unhidewhenused="false" name="Light Grid Accent 1"> <w:lsdexception locked="false" priority="63" semihidden="false" unhidewhenused="false" name="Medium Shading 1 Accent 1"> <w:lsdexception locked="false" priority="64" semihidden="false" unhidewhenused="false" name="Medium Shading 2 Accent 1"> <w:lsdexception locked="false" priority="65" semihidden="false" unhidewhenused="false" name="Medium List 1 Accent 1"> <w:lsdexception locked="false" unhidewhenused="false" name="Revision"> <w:lsdexception locked="false" priority="34" semihidden="false" unhidewhenused="false" qformat="true" name="List Paragraph"> <w:lsdexception locked="false" priority="29" semihidden="false" unhidewhenused="false" qformat="true" name="Quote"> <w:lsdexception locked="false" priority="30" semihidden="false" unhidewhenused="false" qformat="true" name="Intense Quote"> <w:lsdexception locked="false" priority="66" semihidden="false" unhidewhenused="false" name="Medium List 2 Accent 1"> <w:lsdexception locked="false" priority="67" semihidden="false" unhidewhenused="false" name="Medium Grid 1 Accent 1"> <w:lsdexception locked="false" priority="68" semihidden="false" unhidewhenused="false" name="Medium Grid 2 Accent 1"> <w:lsdexception locked="false" priority="69" semihidden="false" unhidewhenused="false" name="Medium Grid 3 Accent 1"> <w:lsdexception locked="false" priority="70" semihidden="false" unhidewhenused="false" name="Dark List Accent 1"> <w:lsdexception locked="false" priority="71" semihidden="false" unhidewhenused="false" name="Colorful Shading Accent 1"> <w:lsdexception locked="false" priority="72" semihidden="false" unhidewhenused="false" name="Colorful List Accent 1"> <w:lsdexception locked="false" priority="73" semihidden="false" unhidewhenused="false" name="Colorful Grid Accent 1"> <w:lsdexception locked="false" priority="60" semihidden="false" unhidewhenused="false" name="Light Shading Accent 2"> <w:lsdexception locked="false" priority="61" semihidden="false" unhidewhenused="false" name="Light List Accent 2"> <w:lsdexception locked="false" priority="62" semihidden="false" unhidewhenused="false" name="Light Grid Accent 2"> <w:lsdexception locked="false" priority="63" semihidden="false" unhidewhenused="false" name="Medium Shading 1 Accent 2"> <w:lsdexception locked="false" priority="64" semihidden="false" unhidewhenused="false" name="Medium Shading 2 Accent 2"> <w:lsdexception locked="false" priority="65" semihidden="false" unhidewhenused="false" name="Medium List 1 Accent 2"> <w:lsdexception locked="false" priority="66" semihidden="false" unhidewhenused="false" name="Medium List 2 Accent 2"> <w:lsdexception locked="false" priority="67" semihidden="false" unhidewhenused="false" name="Medium Grid 1 Accent 2"> <w:lsdexception locked="false" priority="68" semihidden="false" unhidewhenused="false" name="Medium Grid 2 Accent 2"> <w:lsdexception locked="false" priority="69" semihidden="false" unhidewhenused="false" name="Medium Grid 3 Accent 2"> <w:lsdexception locked="false" priority="70" semihidden="false" unhidewhenused="false" name="Dark List Accent 2"> <w:lsdexception locked="false" priority="71" semihidden="false" unhidewhenused="false" name="Colorful Shading Accent 2"> <w:lsdexception locked="false" priority="72" semihidden="false" unhidewhenused="false" name="Colorful List Accent 2"> <w:lsdexception locked="false" priority="73" semihidden="false" unhidewhenused="false" name="Colorful Grid Accent 2"> <w:lsdexception locked="false" priority="60" semihidden="false" unhidewhenused="false" name="Light Shading Accent 3"> <w:lsdexception locked="false" priority="61" semihidden="false" unhidewhenused="false" name="Light List Accent 3"> <w:lsdexception locked="false" priority="62" semihidden="false" unhidewhenused="false" name="Light Grid Accent 3"> <w:lsdexception locked="false" priority="63" semihidden="false" unhidewhenused="false" name="Medium Shading 1 Accent 3"> <w:lsdexception locked="false" priority="64" semihidden="false" unhidewhenused="false" name="Medium Shading 2 Accent 3"> <w:lsdexception locked="false" priority="65" semihidden="false" unhidewhenused="false" name="Medium List 1 Accent 3"> <w:lsdexception locked="false" priority="66" semihidden="false" unhidewhenused="false" name="Medium List 2 Accent 3"> <w:lsdexception locked="false" priority="67" semihidden="false" unhidewhenused="false" name="Medium Grid 1 Accent 3"> <w:lsdexception locked="false" priority="68" semihidden="false" unhidewhenused="false" name="Medium Grid 2 Accent 3"> <w:lsdexception locked="false" priority="69" semihidden="false" unhidewhenused="false" name="Medium Grid 3 Accent 3"> <w:lsdexception locked="false" priority="70" semihidden="false" unhidewhenused="false" name="Dark List Accent 3"> <w:lsdexception locked="false" priority="71" semihidden="false" unhidewhenused="false" name="Colorful Shading Accent 3"> <w:lsdexception locked="false" priority="72" semihidden="false" unhidewhenused="false" name="Colorful List Accent 3"> <w:lsdexception locked="false" priority="73" semihidden="false" unhidewhenused="false" name="Colorful Grid Accent 3"> <w:lsdexception locked="false" priority="60" semihidden="false" unhidewhenused="false" name="Light Shading Accent 4"> <w:lsdexception locked="false" priority="61" semihidden="false" unhidewhenused="false" name="Light List Accent 4"> <w:lsdexception locked="false" priority="62" semihidden="false" unhidewhenused="false" name="Light Grid Accent 4"> <w:lsdexception locked="false" priority="63" semihidden="false" unhidewhenused="false" name="Medium Shading 1 Accent 4"> <w:lsdexception locked="false" priority="64" semihidden="false" unhidewhenused="false" name="Medium Shading 2 Accent 4"> <w:lsdexception locked="false" priority="65" semihidden="false" unhidewhenused="false" name="Medium List 1 Accent 4"> <w:lsdexception locked="false" priority="66" semihidden="false" unhidewhenused="false" name="Medium List 2 Accent 4"> <w:lsdexception locked="false" priority="67" semihidden="false" unhidewhenused="false" name="Medium Grid 1 Accent 4"> <w:lsdexception locked="false" priority="68" semihidden="false" unhidewhenused="false" name="Medium Grid 2 Accent 4"> <w:lsdexception locked="false" priority="69" semihidden="false" unhidewhenused="false" name="Medium Grid 3 Accent 4"> <w:lsdexception locked="false" priority="70" semihidden="false" unhidewhenused="false" name="Dark List Accent 4"> <w:lsdexception locked="false" priority="71" semihidden="false" unhidewhenused="false" name="Colorful Shading Accent 4"> <w:lsdexception locked="false" priority="72" semihidden="false" unhidewhenused="false" name="Colorful List Accent 4"> <w:lsdexception locked="false" priority="73" semihidden="false" unhidewhenused="false" name="Colorful Grid Accent 4"> <w:lsdexception locked="false" priority="60" semihidden="false" unhidewhenused="false" name="Light Shading Accent 5"> <w:lsdexception locked="false" priority="61" semihidden="false" unhidewhenused="false" name="Light List Accent 5"> <w:lsdexception locked="false" priority="62" semihidden="false" unhidewhenused="false" name="Light Grid Accent 5"> <w:lsdexception locked="false" priority="63" semihidden="false" unhidewhenused="false" name="Medium Shading 1 Accent 5"> <w:lsdexception locked="false" priority="64" semihidden="false" unhidewhenused="false" name="Medium Shading 2 Accent 5"> <w:lsdexception locked="false" priority="65" semihidden="false" unhidewhenused="false" name="Medium List 1 Accent 5"> <w:lsdexception locked="false" priority="66" semihidden="false" unhidewhenused="false" name="Medium List 2 Accent 5"> <w:lsdexception locked="false" priority="67" semihidden="false" unhidewhenused="false" name="Medium Grid 1 Accent 5"> <w:lsdexception locked="false" priority="68" semihidden="false" unhidewhenused="false" name="Medium Grid 2 Accent 5"> <w:lsdexception locked="false" priority="69" semihidden="false" unhidewhenused="false" name="Medium Grid 3 Accent 5"> <w:lsdexception locked="false" priority="70" semihidden="false" unhidewhenused="false" name="Dark List Accent 5"> <w:lsdexception locked="false" priority="71" semihidden="false" unhidewhenused="false" name="Colorful Shading Accent 5"> <w:lsdexception locked="false" priority="72" semihidden="false" unhidewhenused="false" name="Colorful List Accent 5"> <w:lsdexception locked="false" priority="73" semihidden="false" unhidewhenused="false" name="Colorful Grid Accent 5"> <w:lsdexception locked="false" priority="60" semihidden="false" unhidewhenused="false" name="Light Shading Accent 6"> <w:lsdexception locked="false" priority="61" semihidden="false" unhidewhenused="false" name="Light List Accent 6"> <w:lsdexception locked="false" priority="62" semihidden="false" unhidewhenused="false" name="Light Grid Accent 6"> <w:lsdexception locked="false" priority="63" semihidden="false" unhidewhenused="false" name="Medium Shading 1 Accent 6"> <w:lsdexception locked="false" priority="64" semihidden="false" unhidewhenused="false" name="Medium Shading 2 Accent 6"> <w:lsdexception locked="false" priority="65" semihidden="false" unhidewhenused="false" name="Medium List 1 Accent 6"> <w:lsdexception locked="false" priority="66" semihidden="false" unhidewhenused="false" name="Medium List 2 Accent 6"> <w:lsdexception locked="false" priority="67" semihidden="false" unhidewhenused="false" name="Medium Grid 1 Accent 6"> <w:lsdexception locked="false" priority="68" semihidden="false" unhidewhenused="false" name="Medium Grid 2 Accent 6"> <w:lsdexception locked="false" priority="69" semihidden="false" unhidewhenused="false" name="Medium Grid 3 Accent 6"> <w:lsdexception locked="false" priority="70" semihidden="false" unhidewhenused="false" name="Dark List Accent 6"> <w:lsdexception locked="false" priority="71" semihidden="false" unhidewhenused="false" name="Colorful Shading Accent 6"> <w:lsdexception locked="false" priority="72" semihidden="false" unhidewhenused="false" name="Colorful List Accent 6"> <w:lsdexception locked="false" priority="73" semihidden="false" unhidewhenused="false" name="Colorful Grid Accent 6"> <w:lsdexception locked="false" priority="19" semihidden="false" unhidewhenused="false" qformat="true" name="Subtle Emphasis"> <w:lsdexception locked="false" priority="21" semihidden="false" unhidewhenused="false" qformat="true" name="Intense Emphasis"> <w:lsdexception locked="false" priority="31" semihidden="false" unhidewhenused="false" qformat="true" name="Subtle Reference"> <w:lsdexception locked="false" priority="32" semihidden="false" unhidewhenused="false" qformat="true" name="Intense Reference"> <w:lsdexception locked="false" priority="33" semihidden="false" unhidewhenused="false" qformat="true" name="Book Title"> <w:lsdexception locked="false" priority="37" name="Bibliography"> <w:lsdexception locked="false" priority="39" qformat="true" name="TOC Heading"> </w:LatentStyles> </xml><![endif]--><style> <!-- /* Font Definitions */ @font-face {font-family:"Cambria Math"; panose-1:2 4 5 3 5 4 6 3 2 4; mso-font-charset:1; mso-generic-font-family:roman; mso-font-format:other; mso-font-pitch:variable; mso-font-signature:0 0 0 0 0 0;} @font-face {font-family:Calibri; panose-1:2 15 5 2 2 2 4 3 2 4; mso-font-charset:0; mso-generic-font-family:swiss; mso-font-pitch:variable; mso-font-signature:-520092929 1073786111 9 0 415 0;} /* Style Definitions */ p.MsoNormal, li.MsoNormal, div.MsoNormal {mso-style-unhide:no; mso-style-qformat:yes; mso-style-parent:""; margin-top:0cm; margin-right:0cm; margin-bottom:10.0pt; margin-left:0cm; line-height:115%; mso-pagination:widow-orphan; font-size:11.0pt; font-family:"Calibri","sans-serif"; mso-ascii-font-family:Calibri; mso-ascii-theme-font:minor-latin; mso-fareast-font-family:Calibri; mso-fareast-theme-font:minor-latin; mso-hansi-font-family:Calibri; mso-hansi-theme-font:minor-latin; mso-bidi-font-family:"Times New Roman"; mso-bidi-theme-font:minor-bidi; mso-fareast-language:EN-US;} .MsoChpDefault {mso-style-type:export-only; mso-default-props:yes; mso-ascii-font-family:Calibri; mso-ascii-theme-font:minor-latin; mso-fareast-font-family:Calibri; mso-fareast-theme-font:minor-latin; mso-hansi-font-family:Calibri; mso-hansi-theme-font:minor-latin; mso-bidi-font-family:"Times New Roman"; mso-bidi-theme-font:minor-bidi; mso-fareast-language:EN-US;} .MsoPapDefault {mso-style-type:export-only; margin-bottom:10.0pt; line-height:115%;} @page Section1 {size:595.3pt 841.9pt; margin:72.0pt 72.0pt 72.0pt 72.0pt; mso-header-margin:35.4pt; mso-footer-margin:35.4pt; mso-paper-source:0;} div.Section1 {page:Section1;} --> </style><!--[if gte mso 10]> <style> /* Style Definitions */ table.MsoNormalTable {mso-style-name:"Table Normal"; mso-tstyle-rowband-size:0; mso-tstyle-colband-size:0; mso-style-noshow:yes; mso-style-priority:99; mso-style-qformat:yes; mso-style-parent:""; mso-padding-alt:0cm 5.4pt 0cm 5.4pt; mso-para-margin-top:0cm; mso-para-margin-right:0cm; mso-para-margin-bottom:10.0pt; mso-para-margin-left:0cm; line-height:115%; mso-pagination:widow-orphan; font-size:11.0pt; font-family:"Calibri","sans-serif"; mso-ascii-font-family:Calibri; mso-ascii-theme-font:minor-latin; mso-fareast-font-family:"Times New Roman"; mso-fareast-theme-font:minor-fareast; mso-hansi-font-family:Calibri; mso-hansi-theme-font:minor-latin; mso-bidi-font-family:"Times New Roman"; mso-bidi-theme-font:minor-bidi;} </style> <![endif]--> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Courier New"; color: blue;">#region</span><span style="font-size: 10pt; font-family: "Courier New";"> List To DataTable<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Courier New";"><o:p> </o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Courier New";"><o:p> </o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Courier New";"><span style=""> </span><span style="color: blue;">public</span> <span style="color: blue;">static</span> DataTable ToDataTable<t>(<span style="color: blue;">this</span> <span style="color: rgb(43, 145, 175);">List</span><t> items)<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Courier New";"><span style=""> </span>{<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Courier New";"><span style=""> </span><span style="color: blue;">var</span> tb = <span style="color: blue;">new</span> DataTable(<span style="color: blue;">typeof</span>(T).Name);<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Courier New";"><o:p> </o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Courier New";"><span style=""> </span><span style="color: rgb(43, 145, 175);">PropertyInfo</span>[] props = <span style="color: blue;">typeof</span>(T).GetProperties(<span style="color: rgb(43, 145, 175);">BindingFlags</span>.Public | <span style="color: rgb(43, 145, 175);">BindingFlags</span>.Instance);<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Courier New";"><o:p> </o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Courier New";"><span style=""> </span><span style="color: blue;">foreach</span> (<span style="color: rgb(43, 145, 175);">PropertyInfo</span> prop <span style="color: blue;">in</span> props)<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Courier New";"><span style=""> </span>{<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Courier New";"><span style=""> </span><span style="color: rgb(43, 145, 175);">Type</span> t = GetCoreType(prop.PropertyType);<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Courier New";"><span style=""> </span>tb.Columns.Add(prop.Name, t);<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Courier New";"><span style=""> </span>}<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Courier New";"><o:p> </o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Courier New";"><span style=""> </span><span style="color: blue;">foreach</span> (T item <span style="color: blue;">in</span> items)<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Courier New";"><span style=""> </span>{<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Courier New";"><span style=""> </span><span style="color: blue;">var</span> values = <span style="color: blue;">new</span> <span style="color: blue;">object</span>[props.Length];<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Courier New";"><o:p> </o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Courier New";"><span style=""> </span><span style="color: blue;">for</span> (<span style="color: blue;">int</span> i = 0; i <></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Courier New";"><span style=""> </span>{<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Courier New";"><span style=""> </span>values[i] = props[i].GetValue(item, <span style="color: blue;">null</span>);<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Courier New";"><span style=""> </span>}<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Courier New";"><o:p> </o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Courier New";"><span style=""> </span>tb.Rows.Add(values);<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Courier New";"><span style=""> </span>}<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Courier New";"><o:p> </o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Courier New";"><span style=""> </span><span style="color: blue;">return</span> tb;<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Courier New";"><span style=""> </span>}<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Courier New";"><o:p> </o:p></span></p><p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;">
<br /><span style="font-size: 10pt; font-family: "Courier New";"><o:p></o:p></span></p><p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Courier New";"><o:p>
<br /></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Courier New";"><span style=""> </span><span style="color: gray;">///</span><span style="color: green;"> </span><span style="color: gray;"><summary><o:p></o:p></span></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Courier New";"><span style=""> </span><span style="color: gray;">///</span><span style="color: green;"> Determine of specified type is nullable<o:p></o:p></span></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Courier New";"><span style=""> </span><span style="color: gray;">///</span><span style="color: green;"> </span><span style="color: gray;"></summary><o:p></o:p></span></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Courier New";"><span style=""> </span><span style="color: blue;">public</span> <span style="color: blue;">static</span> <span style="color: blue;">bool</span> IsNullable(<span style="color: rgb(43, 145, 175);">Type</span> t)<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Courier New";"><span style=""> </span>{<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Courier New";"><span style=""> </span><span style="color: blue;">return</span> !t.IsValueType || (t.IsGenericType && t.GetGenericTypeDefinition() == <span style="color: blue;">typeof</span>(<span style="color: rgb(43, 145, 175);">Nullable</span><>));<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Courier New";"><span style=""> </span>}<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Courier New";"><o:p> </o:p></span></p><p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;">
<br /><span style="font-size: 10pt; font-family: "Courier New";"><o:p></o:p></span></p><p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Courier New";"><o:p>
<br /></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Courier New";"><span style=""> </span><span style="color: gray;">///</span><span style="color: green;"> </span><span style="color: gray;"><summary><o:p></o:p></span></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Courier New";"><span style=""> </span><span style="color: gray;">///</span><span style="color: green;"> Return underlying type if type is Nullable otherwise return the type<o:p></o:p></span></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Courier New";"><span style=""> </span><span style="color: gray;">///</span><span style="color: green;"> </span><span style="color: gray;"></summary><o:p></o:p></span></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Courier New";"><span style=""> </span><span style="color: blue;">public</span> <span style="color: blue;">static</span> <span style="color: rgb(43, 145, 175);">Type</span> GetCoreType(<span style="color: rgb(43, 145, 175);">Type</span> t)<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Courier New";"><span style=""> </span>{<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Courier New";"><span style=""> </span><span style="color: blue;">if</span> (t != <span style="color: blue;">null</span> && IsNullable(t))<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Courier New";"><span style=""> </span>{<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Courier New";"><span style=""> </span><span style="color: blue;">if</span> (!t.IsValueType)<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Courier New";"><span style=""> </span>{<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Courier New";"><span style=""> </span><span style="color: blue;">return</span> t;<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Courier New";"><span style=""> </span>}<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Courier New";"><span style=""> </span><span style="color: blue;">else<o:p></o:p></span></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Courier New";"><span style=""> </span>{<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Courier New";"><span style=""> </span><span style="color: blue;">return</span> <span style="color: rgb(43, 145, 175);">Nullable</span>.GetUnderlyingType(t);<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Courier New";"><span style=""> </span>}<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Courier New";"><span style=""> </span>}<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Courier New";"><span style=""> </span><span style="color: blue;">else<o:p></o:p></span></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Courier New";"><span style=""> </span>{<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Courier New";"><span style=""> </span><span style="color: blue;">return</span> t;<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Courier New";"><span style=""> </span>}<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Courier New";"><span style=""> </span>}<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Courier New";"><o:p> </o:p></span></p> <p class="MsoNormal"><span style="font-size: 10pt; line-height: 115%; font-family: "Courier New"; color: blue;"><span style=""> </span>#endregion</span></p> Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-7129929778341648750.post-37790906039183408922010-04-29T08:07:00.003+05:302011-01-08T07:11:19.827+05:30IEnumerable to DataTable<link href="file:///E:%5CUsers%5CDhruval%5CAppData%5CLocal%5CTemp%5Cmsohtmlclip1%5C01%5Cclip_filelist.xml" rel="File-List"></link><link href="file:///E:%5CUsers%5CDhruval%5CAppData%5CLocal%5CTemp%5Cmsohtmlclip1%5C01%5Cclip_themedata.thmx" rel="themeData"></link><link href="file:///E:%5CUsers%5CDhruval%5CAppData%5CLocal%5CTemp%5Cmsohtmlclip1%5C01%5Cclip_colorschememapping.xml" rel="colorSchemeMapping"></link> <m:smallfrac val="off"> <m:dispdef> <m:lmargin val="0"> <m:rmargin val="0"> <m:defjc val="centerGroup"> <m:wrapindent val="1440"> <m:intlim val="subSup"> <m:narylim val="undOvr"> </m:narylim></m:intlim> </m:wrapindent><style>
<!-- /* Font Definitions */ @font-face {font-family:"Cambria Math"; panose-1:2 4 5 3 5 4 6 3 2 4; mso-font-charset:1; mso-generic-font-family:roman; mso-font-format:other; mso-font-pitch:variable; mso-font-signature:0 0 0 0 0 0;} @font-face {font-family:Calibri; panose-1:2 15 5 2 2 2 4 3 2 4; mso-font-charset:0; mso-generic-font-family:swiss; mso-font-pitch:variable; mso-font-signature:-520092929 1073786111 9 0 415 0;} /* Style Definitions */ p.MsoNormal, li.MsoNormal, div.MsoNormal {mso-style-unhide:no; mso-style-qformat:yes; mso-style-parent:""; margin-top:0cm; margin-right:0cm; margin-bottom:10.0pt; margin-left:0cm; line-height:115%; mso-pagination:widow-orphan; font-size:11.0pt; font-family:"Calibri","sans-serif"; mso-ascii-font-family:Calibri; mso-ascii-theme-font:minor-latin; mso-fareast-font-family:Calibri; mso-fareast-theme-font:minor-latin; mso-hansi-font-family:Calibri; mso-hansi-theme-font:minor-latin; mso-bidi-font-family:"Times New Roman"; mso-bidi-theme-font:minor-bidi; mso-fareast-language:EN-US;} .MsoChpDefault {mso-style-type:export-only; mso-default-props:yes; mso-ascii-font-family:Calibri; mso-ascii-theme-font:minor-latin; mso-fareast-font-family:Calibri; mso-fareast-theme-font:minor-latin; mso-hansi-font-family:Calibri; mso-hansi-theme-font:minor-latin; mso-bidi-font-family:"Times New Roman"; mso-bidi-theme-font:minor-bidi; mso-fareast-language:EN-US;} .MsoPapDefault {mso-style-type:export-only; margin-bottom:10.0pt; line-height:115%;} @page Section1 {size:595.3pt 841.9pt; margin:72.0pt 72.0pt 72.0pt 72.0pt; mso-header-margin:35.4pt; mso-footer-margin:35.4pt; mso-paper-source:0;} div.Section1 {page:Section1;} -->
</style> </m:defjc></m:rmargin></m:lmargin></m:dispdef></m:smallfrac><br />
<div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><span style="font-family: "Courier New"; font-size: 10pt;"> <span style="color: blue;">public</span> <span style="color: blue;">static</span> DataTable ToDataTable(<span style="color: blue;">this</span> <span style="color: #2b91af;">IEnumerable</span> ien)<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><span style="font-family: "Courier New"; font-size: 10pt;"> {<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><span style="font-family: "Courier New"; font-size: 10pt;"> DataTable dt = <span style="color: blue;">new</span> DataTable();<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><span style="font-family: "Courier New"; font-size: 10pt;"> <span style="color: blue;">foreach</span> (<span style="color: blue;">object</span> obj <span style="color: blue;">in</span> ien)<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><span style="font-family: "Courier New"; font-size: 10pt;"> {<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><span style="font-family: "Courier New"; font-size: 10pt;"> <span style="color: #2b91af;">Type</span> t = obj.GetType();<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><span style="font-family: "Courier New"; font-size: 10pt;"> <span style="color: #2b91af;">PropertyInfo</span>[] pis = t.GetProperties();<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><span style="font-family: "Courier New"; font-size: 10pt;"> <span style="color: blue;">if</span> (dt.Columns.Count == 0)<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><span style="font-family: "Courier New"; font-size: 10pt;"> {<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><span style="font-family: "Courier New"; font-size: 10pt;"> <span style="color: blue;">foreach</span> (<span style="color: #2b91af;">PropertyInfo</span> pi <span style="color: blue;">in</span> pis)<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><span style="font-family: "Courier New"; font-size: 10pt;"> {<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><span style="font-family: "Courier New"; font-size: 10pt;"> </span> <m:smallfrac m:val="off"> <m:dispdef> <m:lmargin m:val="0"> <m:rmargin m:val="0"> <m:defjc m:val="centerGroup"> <m:wrapindent m:val="1440"> <m:intlim m:val="subSup"> <m:narylim m:val="undOvr"> </m:narylim></m:intlim> </m:wrapindent> </m:defjc></m:rmargin></m:lmargin></m:dispdef></m:smallfrac></div><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><span style="color: #2b91af; font-family: "Courier New"; font-size: 10pt;">Type</span><span style="font-family: "Courier New"; font-size: 10pt;"> propType = pi.PropertyType;</span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><br />
</div><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><span style="font-family: "Courier New"; font-size: 10pt;"> <span style="color: green;">// Is it a nullable type? Get the underlying type</span></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><span style="font-family: "Courier New"; font-size: 10pt;"> <span style="color: blue;">if</span> (propType.IsGenericType && propType.GetGenericTypeDefinition().Equals(<span style="color: blue;">typeof</span>(<span style="color: #2b91af;">Nullable</span><>)))</span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><span style="font-family: "Courier New"; font-size: 10pt;"> </span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><span style="font-family: "Courier New"; font-size: 10pt;"> propType = <span style="color: blue;">new</span> System.ComponentModel.<span style="color: #2b91af;">NullableConverter</span>(propType).UnderlyingType;</span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><br />
</div><div class="MsoNormal"><span style="font-family: "Courier New"; font-size: 10pt; line-height: 115%;"> dt.Columns.Add(pi.Name, propType);</span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><span style="font-family: "Courier New"; font-size: 10pt;"><br />
<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><span style="font-family: "Courier New"; font-size: 10pt;"> }<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><span style="font-family: "Courier New"; font-size: 10pt;"> }<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><span style="font-family: "Courier New"; font-size: 10pt;"> DataRow dr = dt.NewRow();<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><span style="font-family: "Courier New"; font-size: 10pt;"> <span style="color: blue;">foreach</span> (<span style="color: #2b91af;">PropertyInfo</span> pi <span style="color: blue;">in</span> pis)<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><span style="font-family: "Courier New"; font-size: 10pt;"> {<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><span style="font-family: "Courier New"; font-size: 10pt;"> <span style="color: blue;">object</span> value = pi.GetValue(obj, <span style="color: blue;">null</span>);<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><span style="font-family: "Courier New"; font-size: 10pt;"> dr[pi.Name] = value;<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><span style="font-family: "Courier New"; font-size: 10pt;"> }<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><span style="font-family: "Courier New"; font-size: 10pt;"> dt.Rows.Add(dr);<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><span style="font-family: "Courier New"; font-size: 10pt;"> }<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><span style="font-family: "Courier New"; font-size: 10pt;"> <span style="color: blue;">return</span> dt;<o:p></o:p></span></div><div class="MsoNormal"><span style="font-family: "Courier New"; font-size: 10pt; line-height: 115%;"> }</span></div>Unknownnoreply@blogger.com1tag:blogger.com,1999:blog-7129929778341648750.post-40376722741010645822010-03-31T21:28:00.001+05:302010-03-31T21:30:15.187+05:30Get Identity value after Insert in LINQ C#<span>// Create object of entity<br /> CustomerSalesInformation obj</span><span id="e3a827ef-0e34-43d8-8c1d-c7d1cbd3371a">CustomerSalesInformation </span><span id="e3a827ef-0e34-43d8-8c1d-c7d1cbd3371a"> = new CustomerSalesInformation();<br /><br />// Fiil the entity information<br /> obj</span><span id="e3a827ef-0e34-43d8-8c1d-c7d1cbd3371a">CustomerSalesInformation </span><span id="e3a827ef-0e34-43d8-8c1d-c7d1cbd3371a">.Name = "test";<br /><br />// Submit Query<br /> ObjDatatContext.GetTable<customersalesinformation>().InsertOnSubmit(obj</span><span id="e3a827ef-0e34-43d8-8c1d-c7d1cbd3371a">CustomerSalesInformation </span><span id="e3a827ef-0e34-43d8-8c1d-c7d1cbd3371a">);<br /><br />// Submit Changes<br /> ObjDatatContext.SubmitChanges();<br /><br />// Get Inserted ID<br /><br /> obj</span><span id="e3a827ef-0e34-43d8-8c1d-c7d1cbd3371a">CustomerSalesInformation </span><span id="e3a827ef-0e34-43d8-8c1d-c7d1cbd3371a">.Id // Id is primary key column of CustomerSalesInformation Table<br /></span>Unknownnoreply@blogger.com1tag:blogger.com,1999:blog-7129929778341648750.post-38522693384704507562010-03-27T12:35:00.001+05:302010-03-27T12:37:57.384+05:30Accessing Global Resource Files from a Class Library in ASP.NET<div class="postText"> <p> If you add an App_GlobalResources Folder to your asp.net 2.0 web application you may want to access some of the values within it from a class library - such as a Business Logic Layer (BLL). Since there is unlikely to be a reference from your BLL to the main site, and even if there were, the designer class that shadows the resource file is declared with "Friend" keywords so that class would not be visible to the BLL. Therefore trying to call it using the Resources.[Filename].[key] syntax that works from anywhere within the site will not work. Instead you can simply create a wrapper like the following somwhere within your class library: </p> <p> <!-- {\rtf1\ansi\ansicpg\lang1024\noproof1252\uc1 \deff0{\fonttbl{\f0\fnil\fcharset0\fprq1 Courier New;}}{\colortbl;??\red0\green0\blue255;\red255\green255\blue255;\red0\green0\blue0;\red163\green21\blue21;}??\fs20 \cf1 Imports\cf0 System.Resources\par ??\cf1 Imports\cf0 System.Web\par ??\par ??\cf1 Namespace\cf0 Resources\par ?? \cf1 Public\cf0 \cf1 Class\cf0 ResourceWrapper\par ??\par ?? \cf1 Public\cf0 \cf1 Shared\cf0 \cf1 Function\cf0 CS(\cf1 ByVal\cf0 key \cf1 As\cf0 \cf1 String\cf0 ) \cf1 As\cf0 \cf1 String\par ??\cf0 \cf1 Return\cf0 HttpContext.GetGlobalResourceObject(\cf4 "CS"\cf0 , key)\par ?? \cf1 End\cf0 \cf1 Function\par ??\par ??\cf0 \cf1 Public\cf0 \cf1 Shared\cf0 \cf1 Function\cf0 CJ(\cf1 ByVal\cf0 key \cf1 As\cf0 \cf1 String\cf0 ) \cf1 As\cf0 \cf1 String\par ??\cf0 \cf1 Return\cf0 HttpContext.GetGlobalResourceObject(\cf4 "CJ"\cf0 , key)\par ?? \cf1 End\cf0 \cf1 Function\par ??\par ??\cf0 \cf1 Public\cf0 \cf1 Shared\cf0 \cf1 Function\cf0 IC(\cf1 ByVal\cf0 key \cf1 As\cf0 \cf1 String\cf0 ) \cf1 As\cf0 \cf1 String\par ??\cf0 \cf1 Return\cf0 HttpContext.GetGlobalResourceObject(\cf4 "IC"\cf0 , key)\par ?? \cf1 End\cf0 \cf1 Function\par ??\par ??\cf0 \cf1 End\cf0 \cf1 Class\par ??End\cf0 \cf1 Namespace} --> </p> <div style="background-color: white; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; -moz-background-size: auto auto; font-family: Courier New; font-size: 10pt; color: black; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"> <p style="margin: 0px;"> <span style="color: rgb(43, 145, 175);"> 1</span> <span style="color: blue;">Imports</span> System.Resources </p> <p style="margin: 0px;"> <span style="color: rgb(43, 145, 175);"> 2</span> <span style="color: blue;">Imports</span> System.Web </p> <p style="margin: 0px;"> <span style="color: rgb(43, 145, 175);"> 3</span> </p> <p style="margin: 0px;"> <span style="color: rgb(43, 145, 175);"> 4</span> <span style="color: blue;">Namespace</span> Resources </p> <p style="margin: 0px;"> <span style="color: rgb(43, 145, 175);"> 5</span> <span style="color: blue;">Public</span> <span style="color: blue;">Class</span> ResourceWrapper </p> <p style="margin: 0px;"> <span style="color: rgb(43, 145, 175);"> 6</span> </p> <p style="margin: 0px;"> <span style="color: rgb(43, 145, 175);"> 7</span> <span style="color: blue;">Public</span> <span style="color: blue;">Shared</span> <span style="color: blue;">Function</span> Strings1(<span style="color: blue;">ByVal</span> key <span style="color: blue;">As</span> <span style="color: blue;">String</span>) <span style="color: blue;">As</span> <span style="color: blue;">String</span> </p> <p style="margin: 0px;"> <span style="color: rgb(43, 145, 175);"> 8</span> <span style="color: blue;">Return</span> HttpContext.GetGlobalResourceObject(<span style="color: rgb(163, 21, 21);">"Strings1"</span>, key) </p> <p style="margin: 0px;"> <span style="color: rgb(43, 145, 175);"> 9</span> <span style="color: blue;">End</span> <span style="color: blue;">Function</span> </p> <p style="margin: 0px;"> <span style="color: rgb(43, 145, 175);"> 10</span> </p> <p style="margin: 0px;"> <span style="color: rgb(43, 145, 175);"> 11</span> <span style="color: blue;">Public</span> <span style="color: blue;">Shared</span> <span style="color: blue;">Function</span> Strings2(<span style="color: blue;">ByVal</span> key <span style="color: blue;">As</span> <span style="color: blue;">String</span>) <span style="color: blue;">As</span> <span style="color: blue;">String</span> </p> <p style="margin: 0px;"> <span style="color: rgb(43, 145, 175);"> 12</span> <span style="color: blue;">Return</span> HttpContext.GetGlobalResourceObject(<span style="color: rgb(163, 21, 21);">"Strings2"</span>, key) </p> <p style="margin: 0px;"> <span style="color: rgb(43, 145, 175);"> 13</span> <span style="color: blue;">End</span> <span style="color: blue;">Function</span> </p> <p style="margin: 0px;"> <span style="color: rgb(43, 145, 175);"> 14</span> </p> <p style="margin: 0px;"> <span style="color: rgb(43, 145, 175);"> 15</span> <span style="color: blue;">Public</span> <span style="color: blue;">Shared</span> <span style="color: blue;">Function</span> Strings3(<span style="color: blue;">ByVal</span> key <span style="color: blue;">As</span> <span style="color: blue;">String</span>) <span style="color: blue;">As</span> <span style="color: blue;">String</span> </p> <p style="margin: 0px;"> <span style="color: rgb(43, 145, 175);"> 16</span> <span style="color: blue;">Return</span> HttpContext.GetGlobalResourceObject(<span style="color: rgb(163, 21, 21);">"Strings3"</span>, key) </p> <p style="margin: 0px;"> <span style="color: rgb(43, 145, 175);"> 17</span> <span style="color: blue;">End</span> <span style="color: blue;">Function</span> </p> <p style="margin: 0px;"> <span style="color: rgb(43, 145, 175);"> 18</span> </p> <p style="margin: 0px;"> <span style="color: rgb(43, 145, 175);"> 19</span> <span style="color: blue;">End</span> <span style="color: blue;">Class</span> </p> <p style="margin: 0px;"> <span style="color: rgb(43, 145, 175);"> 20</span> <span style="color: blue;">End</span> <span style="color: blue;">Namespace</span> </p> <p style="margin: 0px;"> <br /></p><p style="margin: 0px;"><br /></p><p style="margin: 0px;"><br /></p> <p style="margin: 0px;"> Then you can retrieve values from the resource files from within your class library simply by passing in the key you want to retrieve: </p> <p style="margin: 0px;"> </p> <p style="margin: 0px;"> <!-- {\rtf1\ansi\ansicpg\lang1024\noproof1252\uc1 \deff0{\fonttbl{\f0\fnil\fcharset0\fprq1 Courier New;}}{\colortbl;??\red0\green0\blue0;\red255\green255\blue255;\red163\green21\blue21;}??\fs20 Resources.ResourceWrapper.CS(\cf3 "SiteNameLong"\cf0 )} --> </p> <div style="background-color: white; background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; -moz-background-size: auto auto; font-family: Courier New; font-size: 10pt; color: black; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"> <p style="margin: 0px;"> <span style="color: rgb(43, 145, 175);"> </span>Resources.ResourceWrapper.Strings1(<span style="color: rgb(163, 21, 21);">"SupportEmail"</span>) </p> <p style="margin: 0px;"> </p> <p style="margin: 0px;"> This example assumes that you have created three .resx resource files inside the App_GlobalResources folder of an ASP.Net Web Application, and that you created them within Visual Studio (as opposed to a text editor for example), and that you named the files "Strings1.resx", "Strings2.resx" and "Strings3.resx", and that Strings1.resx contains the key "SupportEmail".<br /></p><p style="margin: 0px;"><br /></p><p style="margin: 0px;"><br /></p> <p style="margin: 0px;"> </p> <p style="margin: 0px;"> The Great thing about adding .resx files in this fashion is that you can actually edit the values in a text editor on the live site without having to recompile and republish your entire project. Having said that, adding new key value pairs in the text editor will not create the properties in the class that shadows it, and removing or renaming existig key value pairs could cause runtime errors so if you need to do anything other than change the value of an existing key, do so within visual studio and republish. </p> </div> </div> </div>Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-7129929778341648750.post-33236833599164635292010-03-25T12:40:00.002+05:302010-03-28T13:44:58.035+05:30Convert List/IEnumerable to DataTable/DataViewHere’s a method to convert a generic List<t> to a DataTable. This can be used with ObjectDataSource so you get automatic sorting, etc.<br /><br />/// <summary><br />/// Convert a List{T} to a DataTable.<br />/// </summary><br />private DataTable ToDataTable<t><t>(List<t><t> items)<br />{<br />var tb = new DataTable(typeof (T).Name);<br /><br />PropertyInfo[] props = typeof (T).GetProperties(BindingFlags.Public BindingFlags.Instance);<br /><br />foreach (PropertyInfo prop in props)<br />{<br />Type t = GetCoreType(prop.PropertyType);<br />tb.Columns.Add(prop.Name, t);<br />}<br /><br />foreach (T item in items)<br />{<br />var values = new object[props.Length];<br /><br />for (int i = 0; i <><br />/// Determine of specified type is nullable<br />/// </summary><br />public static bool IsNullable(Type t)<br />{<br />return !t.IsValueType (t.IsGenericType && t.GetGenericTypeDefinition() == typeof(Nullable<>));<br />}<br /><br />/// <summary><br />/// Return underlying type if type is Nullable otherwise return the type<br />/// </summary><br />public static Type GetCoreType(Type t)<br />{<br />if (t != null && IsNullable(t))<br />{<br />if (!t.IsValueType)<br />{<br />return t;<br />}<br />else<br />{<br />return Nullable.GetUnderlyingType(t);<br />}<br />}<br />else<br />{<br />return t;<br />}<br />}Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-7129929778341648750.post-73817673396655513902010-02-04T23:24:00.000+05:302010-02-04T23:24:55.624+05:30Notify Icon Text vs BalloonTipTextI have a small application that shows a users ip address via a tool tip when it sits in their system tray. Everything is going fine until someone sends me a bug that there was a problem. Investigating this I find that the method I was using to display tool tips in the system menu is somewhat flawed. I was using a notify icon control to show the tool tips while in the system tray. This works but I was setting the Text property of the control like this:<br />
<br />
<br />
<span style="color: #009900;">// old way of setting text, with 64 character limit</span><br />
<span>this.notifyIcon1.Text = "Show me in the toolbar";</span><br />
<br />
This works but only for up to 64 characters. When I was designing the application I was thinking about ip addresses using the v4 format not the v6 format. Sure enough v6 ip addresses kick out more then 64 characters a lot of the time. So the search was on and I found using the balloon text can show more data but is a wee bit harder to use. Balloon tool tips don't show automatically like the text does. You have to use the notify icons MouseMove event and call the ShowBalloonTip method of the notify icon. So the code below solved my issue:<br />
<br />
<br />
<span style="color: #009900;">// set the balloon tip text</span><br />
this.notifyIcon1.BalloonTipText = "Some realy really really really really ................................ text";<br />
<br />
<span style="color: #009900;">// using the MouseMove event to show the balloon tool tip</span><br />
private void notifyIcon1_MouseMove( object sender, MouseEventArgs e )<br />
{<br />
<span style="margin: 10px;">this.notifyIcon1.ShowBalloonTip( 10 );</span><br />
}<br />
<br />
So now when the user mouses over the icon while in the tray they get a very nice looking tool tip. The only issue is the balloon tool tip IS NOT supported on windows 95. An old OS to be sure but some folks are still running it.Unknownnoreply@blogger.com1tag:blogger.com,1999:blog-7129929778341648750.post-59503778716013844902010-01-31T17:27:00.001+05:302010-01-31T17:27:25.551+05:30Access Report Viewer DLL Files for your Application<div class="MsoNormal" style="margin: 0in 0in 0pt;"><span style="font-size: small;">If an application requires the use of Report Viewer Redistributable and needs access to specific .dlls for the application to run, you’ll find this post helpful, <a href="http://drowningintechnicaldebt.com/blogs/dennisbottjer/archive/2006/10/16/Hacking-Report-Viewer-Redistributable.aspx">http://drowningintechnicaldebt.com/blogs/dennisbottjer/archive/2006/10/16/Hacking-Report-Viewer-Redistributable.aspx</a></span><span style="font-size: small;">. </span></div><span style="font-size: small;"><br />
</span><br />
<div class="MsoNormal" style="margin: 0in 0in 0pt;"><span style="font-size: small;">It explains how to extract the necessary .dll files so you can reference them in your application and avoid GAC security errors (e.g., Could not load file or assembly 'Microsoft.ReportViewer.Common, Version=9.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The module was expected to contain an assembly manifest.)</span></div><span style="font-size: small;"><br />
</span><br />
<div class="MsoNormal" style="margin: 0in 0in 0pt;"><span style="font-size: small;">I will outline the steps below to avoid another click. ;) I have also added links for the most recent versions of Report Viewer.</span></div><span style="font-size: small;"><br />
</span><br />
<ol style="margin-top: 0in;"><li class="MsoNormal" style="margin: 0in 0in 0pt;"><span style="font-size: small;">Download Report Viewer Redistributable</span> <ol style="margin-top: 0in;"><li class="MsoNormal" style="margin: 0in 0in 0pt;"><span style="font-size: small;">Report Viewer 2005 - <a href="http://www.microsoft.com/downloads/details.aspx?familyid=8a166cac-758d-45c8-b637-dd7726e61367&displaylang=en">http://www.microsoft.com/downloads/details.aspx?familyid=8a166cac-758d-45c8-b637-dd7726e61367&displaylang=en</a> </span></li>
<li class="MsoNormal" style="margin: 0in 0in 0pt;"><span style="font-size: small;">Report Viewer 2008 - <a href="http://www.microsoft.com/downloads/details.aspx?familyid=CC96C246-61E5-4D9E-BB5F-416D75A1B9EF&displaylang=en">http://www.microsoft.com/downloads/details.aspx?familyid=CC96C246-61E5-4D9E-BB5F-416D75A1B9EF&displaylang=en</a></span></li>
<li class="MsoNormal" style="margin: 0in 0in 0pt;"><span style="font-size: small;">Report Viewer 2008 SP1 - <a href="http://www.microsoft.com/downloads/details.aspx?familyid=BB196D5D-76C2-4A0E-9458-267D22B6AAC6&displaylang=en">http://www.microsoft.com/downloads/details.aspx?familyid=BB196D5D-76C2-4A0E-9458-267D22B6AAC6&displaylang=en</a> </span></li>
</ol></li>
<li class="MsoNormal" style="margin: 0in 0in 0pt;"><span style="font-size: small;">Use favorite Zip Utility to extract the MSI.exe to a folder of your choice </span></li>
<li class="MsoNormal" style="margin: 0in 0in 0pt;"><span style="font-size: small;">Find the file ReportV1.cab in extract folder from step #2 </span></li>
<li class="MsoNormal" style="margin: 0in 0in 0pt;"><span style="font-size: small;">Use favorite Zip Utility to extract ReportV1.cab to a folder of your choice </span></li>
<li class="MsoNormal" style="margin: 0in 0in 0pt;"><span style="font-size: small;">Open the new folder from step 4 and find 4 files </span></li>
<li class="MsoNormal" style="margin: 0in 0in 0pt;"><span style="font-size: small;">Rename: FL_Microsoft_ReportViewer_Common_dll_117718_____X86.3643236F_FC70_11D3_A536_0090278A1BB8 To Microsoft.ReportViewer.Common.dll </span></li>
<li class="MsoNormal" style="margin: 0in 0in 0pt;"><span style="font-size: small;">Rename: FL_Microsoft_ReportViewer_ProcessingObject_125592_____X86.3643236F_FC70_11D3_A536_0090278A1BB8 To Microsoft.ReportViewer.ProcessingObjectModel.dll </span></li>
<li class="MsoNormal" style="margin: 0in 0in 0pt;"><span style="font-size: small;">Rename: FL_Microsoft_ReportViewer_WebForms_dll_117720_____X86.3643236F_FC70_11D3_A536_0090278A1BB8 To Microsoft.ReportViewer.WebForms.dll </span></li>
<li class="MsoNormal" style="margin: 0in 0in 0pt;"><span style="font-size: small;">Rename: FL_Microsoft_ReportViewer_WinForms_dll_117722_____X86.3643236F_FC70_11D3_A536_0090278A1BB8 To Microsoft.ReportViewer.WinForms.dll </span></li>
<li class="MsoNormal" style="margin: 0in 0in 0pt;"><span style="font-size: small;">Copy these dlls to your smart client project and reference them </span></li>
<li class="MsoNormal" style="margin: 0in 0in 0pt;"><span style="font-size: small;">Now they will be part of the Smart Client's Build Output and Click Once Deployment</span></li>
</ol>Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-7129929778341648750.post-67279443861727185822010-01-30T22:39:00.001+05:302010-01-30T22:41:42.951+05:30Authentication<meta content="text/html; charset=utf-8" http-equiv="Content-Type"></meta><meta content="Word.Document" name="ProgId"></meta><meta content="Microsoft Word 12" name="Generator"></meta><meta content="Microsoft Word 12" name="Originator"></meta><link href="file:///E:%5CUsers%5CDhruval%5CAppData%5CLocal%5CTemp%5Cmsohtmlclip1%5C01%5Cclip_filelist.xml" rel="File-List"></link><link href="file:///E:%5CUsers%5CDhruval%5CAppData%5CLocal%5CTemp%5Cmsohtmlclip1%5C01%5Cclip_themedata.thmx" rel="themeData"></link><link href="file:///E:%5CUsers%5CDhruval%5CAppData%5CLocal%5CTemp%5Cmsohtmlclip1%5C01%5Cclip_colorschememapping.xml" rel="colorSchemeMapping"></link> <m:smallfrac m:val="off"> <m:dispdef> <m:lmargin m:val="0"> <m:rmargin m:val="0"> <m:defjc m:val="centerGroup"> <m:wrapindent m:val="1440"> <m:intlim m:val="subSup"> <m:narylim m:val="undOvr"> </m:narylim></m:intlim> </m:wrapindent><style>
<!--
/* Font Definitions */
@font-face
{font-family:"Cambria Math";
panose-1:2 4 5 3 5 4 6 3 2 4;
mso-font-charset:1;
mso-generic-font-family:roman;
mso-font-format:other;
mso-font-pitch:variable;
mso-font-signature:0 0 0 0 0 0;}
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;
mso-font-charset:0;
mso-generic-font-family:swiss;
mso-font-pitch:variable;
mso-font-signature:-520092929 1073786111 9 0 415 0;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{mso-style-unhide:no;
mso-style-qformat:yes;
mso-style-parent:"";
margin-top:0cm;
margin-right:0cm;
margin-bottom:10.0pt;
margin-left:0cm;
line-height:115%;
mso-pagination:widow-orphan;
font-size:11.0pt;
font-family:"Calibri","sans-serif";
mso-ascii-font-family:Calibri;
mso-ascii-theme-font:minor-latin;
mso-fareast-font-family:Calibri;
mso-fareast-theme-font:minor-latin;
mso-hansi-font-family:Calibri;
mso-hansi-theme-font:minor-latin;
mso-bidi-font-family:"Times New Roman";
mso-bidi-theme-font:minor-bidi;
mso-fareast-language:EN-US;}
p
{mso-style-noshow:yes;
mso-style-priority:99;
mso-margin-top-alt:auto;
margin-right:0cm;
mso-margin-bottom-alt:auto;
margin-left:0cm;
mso-pagination:widow-orphan;
font-size:12.0pt;
font-family:"Times New Roman","serif";
mso-fareast-font-family:"Times New Roman";}
.MsoChpDefault
{mso-style-type:export-only;
mso-default-props:yes;
mso-ascii-font-family:Calibri;
mso-ascii-theme-font:minor-latin;
mso-fareast-font-family:Calibri;
mso-fareast-theme-font:minor-latin;
mso-hansi-font-family:Calibri;
mso-hansi-theme-font:minor-latin;
mso-bidi-font-family:"Times New Roman";
mso-bidi-theme-font:minor-bidi;
mso-fareast-language:EN-US;}
.MsoPapDefault
{mso-style-type:export-only;
margin-bottom:10.0pt;
line-height:115%;}
@page Section1
{size:595.3pt 841.9pt;
margin:72.0pt 72.0pt 72.0pt 72.0pt;
mso-header-margin:35.4pt;
mso-footer-margin:35.4pt;
mso-paper-source:0;}
div.Section1
{page:Section1;}
-->
</style> Security is one of the most important concerns in application software development. Building a robust security model is one of the most important factors that drive the success of application software. As far as security in ASP.NET is concerned, three terms come into my mind, i.e., Authentication, Authorization and Impersonation. Put simply, authentication authenticates the user’s credentials and authorization relates to the resources that an authenticated user has access to. This article is the first in a series of articles on ASP.NET security and discusses these concepts and their applicability.<br />
Let us start our discussion with a brief outline on the sequence of events are as far as authentication and authorization are concerned when a new request comes in. When a new request arrives at IIS, it first checks the validity of the incoming request. If the authentication mode is anonymous (default) then the request is authenticated automatically. But if the authentication mode is overridden in the web.config file settings, IIS performs the specified authentication check before the request is passed on to ASP.NET.<br />
<br />
<b>Authentication</b><br />
Authentication determines whether a user is valid or not based on the user’s credentials. Note that a user can be authorized to access the resources provided the user is an authenticated user. The application’s web.config file contains all of the configuration settings for an ASP.NET application. An authentication provider is used to prove the identity of the users in a system. There are three ways to authenticate a user in ASP.NET:<br />
Forms authentication<br />
Windows authentication<br />
Passport authentication<br />
<br />
<b>Forms Authentication</b><br />
This is based on cookies where the user name and the password are stored either in a text file or a database. It supports both session and persistent cookies. After a user is authenticated, the user’s credentials are stored in a cookie for use in that session. When the user has not logged in and requests for a page that is secured, he or she is redirected to the login page of the application. The following code snippet illustrates how this can be implemented in ASP.NET.<br />
<br />
<o:p></o:p><br />
<configuration> <b>Windows Authentication</b></configuration><br />
Windows Authentication is used to validate a user based on the user’s Windows Account; however, this is only applicable in intranet environments where the administrator has full control over the users in the network. The following code snippet illustrates how we can implement Windows Authentication in ASP.NET.<br />
<br />
<b>Passport Authentication</b><br />
Passport authentication is a centralized authentication service that uses Microsoft’s Passport Service to authenticate the users of an application. It allows the users to create a single sign-in name and password to access any site that has implemented the Passport single sign-in (SSI) service. The following code snippet illustrates how we can implement Passport Authentication in ASP.NET.<br />
<b> </b><br />
<b>Authorization</b><br />
Authorization is the process of determining the accessibility to a resource for a previously authenticated user. Note that authorization can only work on authenticated users, hence ensuring that no un-authenticated user can access the application. The syntax for specifying authorization in ASP.NET is as follows.<o:p></o:p><br />
<authorization><br />
< [ allow | deny ] [ users ] [ roles ] [ verbs ] /><br />
<br />
</authorization><br />
In ASP.NET, there are the following types of authorizations.<br />
URL Authorization<br />
File Authorization<br />
Authorization based on ACL (Access Control List)<br />
<br />
<b>Impersonation</b><br />
According to MSDN, “When using impersonation, ASP.NET applications can optionally execute with the identity of the client on whose behalf they are operating. The usual reason for doing this is to avoid dealing with authentication and authorization issues in the ASP.NET application code. Instead, you rely on Microsoft Internet Information Services (IIS) to authenticate the user and either pass an authenticated token to the ASP.NET application or, if unable to authenticate the user, pass an unauthenticated token. In either case, the ASP.NET application impersonates whichever token is received if impersonation is enabled. The ASP.NET application, now impersonating the client, then relies on the settings in the NTFS directories and files to allow it to gain access, or not. Be sure to format the server file space as NTFS, so that access permissions can be set”.<br />
Note that Impersonation is disabled by default and can be specified in the web.config file as shown in the code snippet given below.<br />
or<br />
<identity impersonate="”false”/"></identity>To impersonate a particular identity, specify the following in your application’s web.config file.<o:p></o:p><br />
</m:defjc></m:rmargin></m:lmargin></m:dispdef></m:smallfrac><br />
<div class="MsoNormal"><br />
</div>Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-7129929778341648750.post-83513399087080486082010-01-30T19:44:00.000+05:302010-01-30T19:44:06.138+05:30A Preview of What's New in C# 3.0On the heels of the Visual Studio 2005 and C# 2.0 releases, Microsoft has given a sneak preview of what to expect in the version after the next: C# 3.0. Even though C# 3.0 is not even standardized yet, Microsoft provided a preview release at its Professional Developers Conference (PDC) in September so eager developers could try out some of the expected features. This article discusses the following major new enhancements expected in C# 3.0:<br />
<ul><li>Implicitly typed local variables </li>
<li>Anonymous types </li>
<li>Extension methods </li>
<li>Object and collection initializers </li>
<li>Lambda expressions </li>
<li>Query expressions </li>
<li>Expression Trees </li>
</ul><h3>Implicitly Typed Local Variables</h3>C# 3.0 introduces a new keyword called "var". Var allows you to declare a new variable, whose type is implicitly inferred from the expression used to initialize the variable. In other words, the following is valid syntax in C# 3.0:<br />
<pre>var i = 1;</pre>The preceding line initializes the variable i to value 1 and gives it the type of integer. Note that "i" is strongly typed to an integer—it is not an object or a VB6 variant, nor does it carry the overhead of an object or a variant.<br />
<script type="text/javascript">
initArticleMenu(document.getElementById("toolBoxShareMenu"));
</script>To ensure the strongly typed nature of the variable that is declared with the var keyword, C# 3.0 requires that you put the assignment (initializer) on the same line as the declaration (declarator). Also, the initializer has to be an expression, not an object or collection initializer, and it cannot be null. If multiple declarators exist on the same variable, they must all evaluate to the same type at compile time.<br />
Implicitly typed arrays, on the other hand, are possible using a slightly different syntax, as shown below:<br />
<pre>var intArr = new[] {1,2,3,4} ;</pre>The above line of code would end up declaring intArr as int[].<br />
The var keyword allows you to refer to instances of anonymous types (described in the next section) and yet the instances are statically typed. So, when you create instances of a class that contain an arbitrary set of data, you don't need to predefine a class to both hold that structure and be able to hold that data in a statically typed variable.<br />
<h3>Anonymous Types</h3>C# 3.0 gives you the flexibility to create an instance of a class without having to write code for the class beforehand. So, you now can write code as shown below:<br />
<pre>new {hair="black", skin="green", teethCount=64}</pre>The preceding line of code, with the help of the "new" keyword, gives you a new type that has three properties: hair, skin, and teethCount. Behind the scenes, the C# compiler would create a class that looks as follows:<br />
<pre>class __Anonymous1
{
private string _hair = "black";
private string _skin = "green";
private int _teeth = 64;
public string hair {get { return _hair; } set { _hair = value; }}
public string skin {get { return _skin; } set { _skin = value; }}
public int teeth {get { return _teeth; } set { _teeth = value; }}
}</pre>In fact, if another anonymous type that specified the same sequence of names and types were created, the compiler would be smart enough to create only a single anonymous type for both instances to use. Also, because the instances are, as you may have guessed, simply instances of the same class, they can be exchanged because the types are really the same.<br />
Now you have a class, but you still need something to hold an instance of the above class. This is where the "var" keyword comes in handy; it lets you hold a statically typed instance of the above instance of the anonymous type. Here is a rather simple and easy use of an anonymous type:<br />
<pre>var frankenstein = new {hair="black", skin="green", teethCount=64}</pre><h3>Extension Methods</h3>Extension methods enable you to extend various types with additional static methods. However, they are quite limited and should be used as a last resort—only where instance methods are insufficient.<br />
Extension methods can be declared only in static classes and are identified by the keyword "this" as a modifier on the first parameter of the method. The following is an example of a valid extension method:<br />
<pre>public static int ToInt32(this string s)
{
return Convert.ToInt32(s) ;
}</pre>If the static class that contains the above method is imported using the "using" keyword, the ToInt32 method will appear in existing types (albeit in lower precedence to existing instance methods), and you will be able to compile and execute code that looks as follows:<br />
<pre>string s = "1";
int i = s.ToInt32();</pre>This allows you to take advantage of the extensible nature of various built-in or defined types and add newer methods to them.<br />
<h3>Object and Collection Initializers</h3>C# 3.0 is expected to allow you to include an initializer that specifies the initial values of the members of a newly created object or collection. This enables you to combine declaration and initialization in one step.<br />
For instance, if you defined a CoOrdinate class as follows:<br />
<pre>public class CoOrdinate
{
public int x ;
public int y;
}</pre>You then could declare and initialize a CoOrdinate object using an object initializer, like this:<br />
<pre>var myCoOrd = new CoOrdinate{ x = 0, y= 0} ;</pre>The above code may have made you raise your eyebrows and ask, "Why not just write the following:"<br />
<pre>var myCoOrd = new CoOrdinate(0, 0) ;</pre><blockquote><b>Note:</b> I never declared a constructor that accepted two parameters in my class. In fact, initializing the object using an object initializer essentially is equivalent to calling a parameterless (default) constructor of the CoOrdinate object and then assigning the relevant values.</blockquote>Similarly, you should easily be able to give values to collections in a rather concise and compact manner in C# 3.0. For instance, the following C# 2.0 code:<br />
<pre>List<string> animals = new List<string>();
animals.Add("monkey");
animals.Add("donkey");
animals.Add("cow");
animals.Add("dog");
animals.Add("cat");</string></string></pre>Now can be shortened to simply:<br />
<pre>List<string> animals = new List<string> {
"monkey", "donkey", "cow", "dog", "cat" } ;</string></string></pre><pre></pre><h3>Lambda Expressions: The Espresso of Anonymous Methods</h3>C# 1.x allowed you to write code blocks in methods, which you could invoke easily using delegates. Delegates are definitely useful, and they are used throughout the framework, but in many instances you had to declare a method or a class just to use one. Thus, to give you an easier and more concise way of writing code, C# 2.0 allowed you to replace standard calls to delegates with anonymous methods. The following code may have been written in .NET 1.1 or earlier:<br />
class Program { delegate void DemoDelegate(); static void Main(string[] args) { DemoDelegate myDelegate = new DemoDelegate(SayHi); myDelegate(); } void SayHi() { Console.Writeline("Hiya!!") ; } } In C# 2.0, using anonymous methods, you could rewrite the code as follows:<br />
class Program { delegate void DemoDelegate(); static void Main(string[] args) { DemoDelegate myDelegate = delegate() { Console.Writeline("Hiya!!"); }; myDelegate(); } }<br />
<br />
<script type="text/javascript">
</script><br />
<script type="text/javascript">
initArticleMenu(document.getElementById("toolBoxShareMenu"));
</script><br />
Whereas anonymous methods are a step above method-based delegate invocation, lambda expressions allow you to write anonymous methods in a more concise, functional syntax.<br />
You can write a lambda expression as a parameter list, followed by the => token, followed by an expression or statement block. The above code can now be replaced with the following code:<br />
class Program { delegate void DemoDelegate(); static void Main(string[] args) { DemoDelegate myDelegate = () => Console.WriteLine("Hiya!!") ; myDelegate(); } } Although Lambda expressions may appear to be simply a more concise way of writing anonymous methods, in reality they also are a functional superset of anonymous methods. Specifically, Lambda expressions offer the following additional functionality:<br />
<ul><li>They permit parameter types to be inferred. Anonymous methods will require you to explicitly state each and every type.</li>
<li>They can hold either query expressions (described in the following section) or C# statements.</li>
<li>They can be treated as data using expression trees (described later). This cannot be done using Anonymous methods.</li>
</ul><h3>Query Expressions</h3>Even though further enhancements may be introduced in the coming months as C# 3.0 matures, the new features described in the preceding sections make it a lot easier to work with data inside C# in general. This feature, also known as LINQ (Language Integrated Query), allows you to write SQL-like syntax in C#.<br />
For instance, you may have a class that describes your data as follows:<br />
public class CoOrdinate { public int x ; public int y; } You now could easily declare the logical equivalent of a database table inside C# as follows:<br />
// Use Object and collection initializers List<coordinate> coords = ... ; And now that you have your data as a collection that implements IEnumerable<t>, you easily can query this data as follows:</t><br />
var filteredCoords = from c in coords where x == 1 select (c.x, c.y) In the SQL-like syntax above, "from", "where", and "select" are query expressions that take advantage of C# 3.0 features such as anonymous types, extension methods, implicit typed local variables, and so forth. This way, you can leverage SQL-like syntax and work with disconnected data easily.<br />
Each query expression is actually translated into a C#-like invocation behind the scenes. For instance, the following:<br />
where x == 1 Translates to this:<br />
coords.where(c => c.x == 1) As you can see, the above looks an awful lot like a lambda expression and extension method. C# 3.0 has many other query expressions and rules that surround them.<br />
<h3>Expression Trees</h3>C# 3.0 includes a new type that allows expressions to be treated as data at runtime. This type, System.Expressions.Expression<t>, is simply an in-memory representation of a lambda expression. The end result is that your code can modify and inspect lambda expressions at runtime.</t><br />
The following is an example of an expression tree:<br />
Expression<demodelegate> filter = () => Console.WriteLine("Hiya!!") ; With the above expression tree setup, you easily can inspect the contents of the tree by using various properties on the filter variable.<br />
<h3>One to Grow On</h3>C# 3.0 offers incredible new features that make your work as an application developer and architect a lot easier, and yet it remains a programming language that lends itself to stricter and cleaner architecture.<br />
C# 3.0 is in its infancy right now and it will mature in the coming months, but given the sizable impact its changes will have on the surrounding .NET Framework, its recommended architecture, and design patterns, definitely keep your eye on it.</demodelegate></coordinate>Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-7129929778341648750.post-11964642418262646612010-01-30T19:41:00.000+05:302010-01-30T19:41:13.825+05:30Query Expressions<b>Query expressions</b> provide a language integrated syntax for queries that is similar to relational and hierarchical query languages such as SQL and XQuery.<br />
<pre class="code">query-expression:
from-clause query-body
from-clause:
from from-generators
from-generators:
from-generator
from-generators , from-generator
from-generator:
identifier in expression
query-body:
from-or-where-clauses<sub>opt</sub> orderby-clause<sub>opt</sub> select-or-group-clause into-clause<sub>opt</sub>
from-or-where-clauses:
from-or-where-clause
from-or-where-clauses from-or-where-clause
from-or-where-clause:
from-clause
where-clause
where-clause:
where boolean-expression
orderby-clause:
orderby ordering-clauses
ordering-clauses:
ordering-clause
ordering-clauses , ordering-clause
ordering-clause:
expression ordering-direction<sub>opt</sub>
ordering-direction:
ascending
descending
select-or-group-clause:
select-clause
group-clause
select-clause:
select expression
group-clause:
group expression by expression
into-clause:
into identifier query-body</pre>A query-expression is classified as a non-assignment-expression, the definition of which occurs in §26.3.<br />
A query expression begins with a <b>from</b> clause and ends with either a <b>select</b> or <b>group</b> clause. The initial <b>from</b> clause can be followed by zero or more <b>from</b> or <b>where</b> clauses. Each <b>from</b> clause is a generator that introduces an iteration variable ranging over a sequence, and each <b>where</b> clause is a filter that excludes items from the result. The final <b>select</b> or <b>group</b> clause specifies the shape of the result in terms of the iteration variable(s). The <b>select</b> or <b>group</b> clause may be preceded by an <b>orderby</b> clause that specifies an ordering for the result. Finally, an <b>into</b> clause can be used to "splice" queries by treating the results of one query as a generator in a subsequent query.<br />
In a query expression, a <b>from</b> clause with multiple generators is exactly equivalent to multiple consecutive <b>from</b> clauses with a single generator.<br />
<h3 class="dtH1">Query Expression Translation</h3>The C# 3.0 language does not specify the exact execution semantics of query expressions. Rather, C# 3.0 translates query expressions into invocations of methods that adhere to the <i>query expression pattern</i>. Specifically, query expressions are translated into invocations of methods named <b>Where</b>, <b>Select</b>, <b>SelectMany</b>, <b>OrderBy</b>, <b>OrderByDescending</b>, <b>ThenBy</b>, <b>ThenByDescending</b>, and <b>GroupBy</b> that are expected to have particular signatures and result types, as described in §26.7.2. These methods can be instance methods of the object being queried or extension methods that are external to the object, and they implement the actual execution of the query.<br />
The translation from query expressions to method invocations is a syntactic mapping that occurs before any type binding or overload resolution has been performed. The translation is guaranteed to be syntactically correct, but it is not guaranteed to produce semantically correct C# code. Following translation of query expressions, the resulting method invocations are processed as regular method invocations, and this may in turn uncover errors, for example if the methods do not exist, if arguments have wrong types, or if the methods are generic and type inference fails.<br />
The translation of query expressions is demonstrated through a series of examples in the following. A formal description of the translation rules is provided in a later section.<br />
<b>where clauses</b><br />
A <b>where</b> clause in a query expression:<br />
<pre class="code">from c in customers
where c.City == "London"
select c</pre>translates to an invocation of a <b>Where</b> method with a synthesized lambda expression created by combining the iteration variable identifier and the expression of the <b>where</b> clause:<br />
<pre class="code">customers.
Where(c => c.City == "London")</pre><b>select clauses</b><br />
The example in the previous section demonstrates how a <b>select</b> clause that selects the innermost iteration variable is erased by the translation to method invocations.<br />
A <b>select</b> clause that selects something other than the innermost iteration variable:<br />
<pre class="code">from c in customers
where c.City == "London"
select c.Name</pre>translates to an invocation of a <b>Select</b> method with a synthesized lambda expression:<br />
<pre class="code">customers.
Where(c => c.City == "London").
Select(c => c.Name)</pre><b>group clauses</b><br />
A <b>group</b> clause:<br />
<pre class="code">from c in customers
group c.Name by c.Country</pre>translates to an invocation of a <b>GroupBy</b> method:<br />
<pre class="code">customers.
GroupBy(c => c.Country, c => c.Name)</pre><b>orderby clauses</b><br />
An <b>orderby</b> clause:<br />
<pre class="code">from c in customers
orderby c.Name
select new { c.Name, c.Phone }</pre>translates to an invocation of an <b>OrderBy</b> method, or an <b>OrderByDescending</b> method if a <b>descending</b> direction was specified:<br />
<pre class="code">customers.
OrderBy(c => c.Name).
Select(c => new { c.Name, c.Phone })</pre>Secondary orderings in an <b>orderby</b> clause:<br />
<pre class="code">from c in customers
orderby c.Country, c.Balance descending
select new { c.Name, c.Country, c.Balance }</pre>translate to invocations of <b>ThenBy</b> and <b>ThenByDescending</b> methods:<br />
<pre class="code">customers.
OrderBy(c => c.Country).
ThenByDescending(c => c.Balance).
Select(c => new { c.Name, c.Country, c.Balance })</pre><b>Multiple generators</b><br />
Multiple generators:<br />
<pre class="code">from c in customers
where c.City == "London"
from o in c.Orders
where o.OrderDate.Year == 2005
select new { c.Name, o.OrderID, o.Total }</pre>translate to invocations of <b>SelectMany</b> for all but the innermost generator:<br />
<pre class="code">customers.
Where(c => c.City == "London").
SelectMany(c =>
c.Orders.
Where(o => o.OrderDate.Year == 2005).
Select(o => new { c.Name, o.OrderID, o.Total })
)</pre>When multiple generators are combined with an <b>orderby</b> clause:<br />
<pre class="code">from c in customers, o in c.Orders
where o.OrderDate.Year == 2005
orderby o.Total descending
select new { c.Name, o.OrderID, o.Total }</pre>an additional <b>Select</b> is injected to collect the ordering expressions and the final result in a sequence of tuples. This is necessary such that <b>OrderBy</b> can operate on the entire sequence. Following <b>OrderBy</b>, the final result is extracted from the tuples:<br />
<pre class="code">customers.
SelectMany(c =>
c.Orders.
Where(o => o.OrderDate.Year == 2005).
Select(o => new { k1 = o.Total, v = new { c.Name, o.OrderID, o.Total } })
).
OrderByDescending(x => x.k1).
Select(x => x.v)</pre><b>into clauses</b><br />
An <b>into</b> clause:<br />
<pre class="code">from c in customers
group c by c.Country into g
select new { Country = g.Key, CustCount = g.Group.Count() }</pre>is simply a more convenient notation for a nested query:<br />
<pre class="code">from g in
from c in customers
group c by c.Country
select new { Country = g.Key, CustCount = g.Group.Count() }</pre>the translation of which is:<br />
<pre class="code">customers.
GroupBy(c => c.Country).
Select(g => new { Country = g.Key, CustCount = g.Group.Count() })</pre><h3 class="dtH1">The Query Expression Pattern</h3>The <b>Query Expression Pattern</b> establishes a pattern of methods that types can implement to support query expressions. Because query expressions are translated to method invocations by means of a syntactic mapping, types have considerable flexibility in how they implement the query expression pattern. For example, the methods of the pattern can be implemented as instance methods or as extension methods because the two have the same invocation syntax, and the methods can request delegates or expression trees because lambda expressions are convertible to both.<br />
The recommended shape of a generic type <b>C<t></t></b> that supports the query expression pattern is shown below. A generic type is used in order to illustrate the proper relationships between parameter and result types, but it is possible to implement the pattern for non-generic types as well.<br />
<pre class="code">delegate R Func<a,r>(A arg);
class C<t>
{
public C<t> Where(Func<t,bool> predicate);
public C<s> Select<s>(Func<t,s> selector);
public C<s> SelectMany<s>(Func<t,c><s>> selector);
public O<t> OrderBy<k>(Func<t,k> keyExpr);
public O<t> OrderByDescending<k>(Func<t,k> keyExpr);
public C<g><k,t>> GroupBy<k>(Func<t,k> keyExpr);
public C<g><k,e>> GroupBy<k,e>(Func<t,k> keyExpr, Func<t,e> elemExpr);
}
class O<t> : C<t>
{
public O<t> ThenBy<k>(Func<t,k> keySelector);
public O<t> ThenByDescending<k>(Func<t,k> keySelector);
}
class G<k,t>
{
public K Key { get; }
public C<t> Group { get; }
}</t></k,t></t,k></k></t></t,k></k></t></t></t></t,e></t,k></k,e></k,e></g></t,k></k></k,t></g></t,k></k></t></t,k></k></t></s></t,c></s></s></t,s></s></s></t,bool></t></t></a,r></pre><s><s><s><s><s> </s></s></s></s></s><s><s><s><s><s>The methods above use a generic delegate type <b>Func<a,></a,></b> <b>R></b>, but they could equally well have used other delegate or expression tree types with the same relationships in parameter and result types.</s></s></s></s></s><br />
<s><s><s><s><s> </s></s></s></s></s><s><s><s><s><s>Notice the recommended relationship between <b>C<t></t></b> and <b>O<t></t></b> which ensures that the <b>ThenBy</b> and <b>ThenByDescending</b> methods are available only on the result of an <b>OrderBy</b> or <b>OrderByDescending</b>. Also notice the recommended shape of the result of <b>GroupBy</b>, which is a sequence of groupings that each has a <b>Key</b> and <b>Group</b> property.</s></s></s></s></s><br />
<s><s><s><s><s> </s></s></s></s></s><s><s><s><s><s>The Standard Query Operators (described in a separate specification) provide an implementation of the query operator pattern for any type that implements the <b>System.Collections.Generic.IEnumerable<t></t></b> interface.</s></s></s></s></s><br />
<s><s><s><s><s> </s></s></s></s></s><h3 class="dtH1"><s _moz-rs-heading=""><s _moz-rs-heading=""><s _moz-rs-heading=""><s _moz-rs-heading=""><s _moz-rs-heading="">Formal Translation Rules</s></s></s></s></s></h3><s><s><s><s><s> </s></s></s></s></s><s><s><s><s><s>A query expression is processed by repeatedly applying the following translations in order. Each translation is applied until there are no more occurrences of the specified pattern.</s></s></s></s></s><br />
<s><s><s><s><s> </s></s></s></s></s><s><s><s><s><s>Note that in the translations that produce invocations of <b>OrderBy</b> and <b>ThenBy</b>, if the corresponding ordering clause specifies a <b>descending</b> direction indicator, an invocation of <b>OrderByDescending</b> or <b>ThenByDescending</b> is produced instead. </s></s></s></s></s><br />
<ul type="disc"><li><s><s><s><s><s>A query that contains an <b>into</b> clause</s></s></s></s></s></li>
</ul><s><s><s><s><s> </s></s></s></s></s><pre class="code"><s><s><s><s><s>q<sub>1</sub> into x q<sub>2</sub></s></s></s></s></s></pre><s><s><s><s><s> </s></s></s></s></s><s><s><s><s><s>is translated into</s></s></s></s></s><br />
<s><s><s><s><s> </s></s></s></s></s><pre class="code"><s><s><s><s><s>from x in ( q<sub>1</sub> ) q<sub>2</sub></s></s></s></s></s></pre><s><s><s><s><s> </s></s></s></s></s><ul type="disc"><li><s><s><s><s><s>A <b>from</b> clause with multiple generators</s></s></s></s></s></li>
</ul><s><s><s><s><s> </s></s></s></s></s><pre class="code"><s><s><s><s><s>from g<sub>1</sub> , g<sub>2</sub> , ... g<sub>n</sub></s></s></s></s></s></pre><s><s><s><s><s> </s></s></s></s></s><s><s><s><s><s>is translated into</s></s></s></s></s><br />
<s><s><s><s><s> </s></s></s></s></s><pre class="code"><s><s><s><s><s>from g<sub>1</sub> from g<sub>2</sub> ... from g<sub>n</sub></s></s></s></s></s></pre><s><s><s><s><s> </s></s></s></s></s><ul type="disc"><li><s><s><s><s><s>A <b>from</b> clause immediately followed by a <b>where</b> clause</s></s></s></s></s></li>
</ul><s><s><s><s><s> </s></s></s></s></s><pre class="code"><s><s><s><s><s>from x in e where f</s></s></s></s></s></pre><s><s><s><s><s> </s></s></s></s></s><s><s><s><s><s>is translated into</s></s></s></s></s><br />
<s><s><s><s><s> </s></s></s></s></s><pre class="code"><s><s><s><s><s>from x in ( e ) . Where ( x => f )</s></s></s></s></s></pre><s><s><s><s><s> </s></s></s></s></s><ul type="disc"><li><s><s><s><s><s>A query expression with multiple <b>from</b> clauses, an <b>orderby</b> clause, and a <b>select</b> clause</s></s></s></s></s></li>
</ul><s><s><s><s><s> </s></s></s></s></s><pre class="code"><s><s><s><s><s>from x<sub>1</sub> in e<sub>1</sub> from x<sub>2</sub> in e<sub>2</sub> ... orderby k<sub>1</sub> , k<sub>2</sub> ... select v</s></s></s></s></s></pre><s><s><s><s><s> </s></s></s></s></s><s><s><s><s><s>is translated into</s></s></s></s></s><br />
<s><s><s><s><s> </s></s></s></s></s><pre class="code"><s><s><s><s><s>( from x<sub>1</sub> in e<sub>1</sub> from x<sub>2</sub> in e<sub>2</sub> ...
select new { k1 = k<sub>1</sub> , k2 = k<sub>2</sub> ... , v = v } )
. OrderBy ( x => x . k1 ) . ThenBy ( x => x . k2 ) ...
. Select ( x => x . v )</s></s></s></s></s></pre><s><s><s><s><s> </s></s></s></s></s><ul type="disc"><li><s><s><s><s><s>A query expression with multiple <b>from</b> clauses, an <b>orderby</b> clause, and a <b>group</b> clause</s></s></s></s></s></li>
</ul><s><s><s><s><s> </s></s></s></s></s><pre class="code"><s><s><s><s><s>from x<sub>1</sub> in e<sub>1</sub> from x<sub>2</sub> in e<sub>2</sub> ... orderby k<sub>1</sub> , k<sub>2</sub> ... group v by g</s></s></s></s></s></pre><s><s><s><s><s> </s></s></s></s></s><s><s><s><s><s>is translated into</s></s></s></s></s><br />
<s><s><s><s><s> </s></s></s></s></s><pre class="code"><s><s><s><s><s>( from x<sub>1</sub> in e<sub>1</sub> from x<sub>2</sub> in e<sub>2</sub> ...
select new { k1 = k<sub>1</sub> , k2 = k<sub>2</sub> ... , v = v , g = g } )
. OrderBy ( x => x . k1 ) . ThenBy ( x => x . k2 ) ...
. GroupBy ( x => x . g , x => x . v )</s></s></s></s></s></pre><s><s><s><s><s> </s></s></s></s></s><ul type="disc"><li><s><s><s><s><s>A query expression with multiple <b>from</b> clauses and a <b>select</b> clause</s></s></s></s></s></li>
</ul><s><s><s><s><s> </s></s></s></s></s><pre class="code"><s><s><s><s><s>from x in e from x<sub>1</sub> in e<sub>1</sub> ... select v</s></s></s></s></s></pre><s><s><s><s><s> </s></s></s></s></s><s><s><s><s><s>is translated into </s></s></s></s></s><br />
<s><s><s><s><s> </s></s></s></s></s><pre class="code"><s><s><s><s><s>( e ) . SelectMany ( x => from x<sub>1</sub> in e<sub>1</sub> ... select v )</s></s></s></s></s></pre><s><s><s><s><s> </s></s></s></s></s><ul type="disc"><li><s><s><s><s><s>A query expression with multiple <b>from</b> clauses and a <b>group</b> clause</s></s></s></s></s></li>
</ul><s><s><s><s><s> </s></s></s></s></s><pre class="code"><s><s><s><s><s>from x in e from x<sub>1</sub> in e<sub>1</sub> ... group v by g</s></s></s></s></s></pre><s><s><s><s><s> </s></s></s></s></s><s><s><s><s><s>is translated into </s></s></s></s></s><br />
<s><s><s><s><s> </s></s></s></s></s><pre class="code"><s><s><s><s><s>( e ) . SelectMany ( x => from x<sub>1</sub> in e<sub>1</sub> ... group v by g )</s></s></s></s></s></pre><s><s><s><s><s> </s></s></s></s></s><ul type="disc"><li><s><s><s><s><s>A query expression with a single <b>from</b> clause, no <b>orderby</b> clause, and a <b>select</b> clause</s></s></s></s></s></li>
</ul><s><s><s><s><s> </s></s></s></s></s><pre class="code"><s><s><s><s><s>from x in e select v</s></s></s></s></s></pre><s><s><s><s><s> </s></s></s></s></s><s><s><s><s><s>is translated into</s></s></s></s></s><br />
<s><s><s><s><s> </s></s></s></s></s><pre class="code"><s><s><s><s><s>( e ) . Select ( x => v )</s></s></s></s></s></pre><s><s><s><s><s> </s></s></s></s></s><s><s><s><s><s>except when v is the identifier x, the translation is simply</s></s></s></s></s><br />
<s><s><s><s><s> </s></s></s></s></s><pre class="code"><s><s><s><s><s>( e )</s></s></s></s></s></pre><s><s><s><s><s> </s></s></s></s></s><ul type="disc"><li><s><s><s><s><s>A query expression with a single <b>from</b> clause, no <b>orderby</b> clause, and a <b>group</b> clause</s></s></s></s></s></li>
</ul><s><s><s><s><s> </s></s></s></s></s><pre class="code"><s><s><s><s><s>from x in e group v by g</s></s></s></s></s></pre><s><s><s><s><s> </s></s></s></s></s><s><s><s><s><s>is translated into</s></s></s></s></s><br />
<s><s><s><s><s> </s></s></s></s></s><pre class="code"><s><s><s><s><s>( e ) . GroupBy ( x => g , x => v )</s></s></s></s></s></pre><s><s><s><s><s> </s></s></s></s></s><s><s><s><s><s>except when v is the identifier x, the translation is</s></s></s></s></s><br />
<s><s><s><s><s> </s></s></s></s></s><pre class="code"><s><s><s><s><s>( e ) . GroupBy ( x => g )</s></s></s></s></s></pre><s><s><s><s><s> </s></s></s></s></s><ul type="disc"><li><s><s><s><s><s>A query expression with a single <b>from</b> clause, an <b>orderby</b> clause, and a <b>select</b> clause</s></s></s></s></s></li>
</ul><s><s><s><s><s> </s></s></s></s></s><pre class="code"><s><s><s><s><s>from x in e orderby k<sub>1</sub> , k<sub>2</sub> ... select v</s></s></s></s></s></pre><s><s><s><s><s> </s></s></s></s></s><s><s><s><s><s>is translated into</s></s></s></s></s><br />
<s><s><s><s><s> </s></s></s></s></s><pre class="code"><s><s><s><s><s>( e ) . OrderBy ( x => k<sub>1</sub> ) . ThenBy ( x => k<sub>2</sub> ) ... . Select ( x => v )</s></s></s></s></s></pre><s><s><s><s><s> </s></s></s></s></s><s><s><s><s><s>except when v is the identifier x, the translation is simply</s></s></s></s></s><br />
<s><s><s><s><s> </s></s></s></s></s><pre class="code"><s><s><s><s><s>( e ) . OrderBy ( x => k<sub>1</sub> ) . ThenBy ( x => k<sub>2</sub> ) ...</s></s></s></s></s></pre><s><s><s><s><s> </s></s></s></s></s><ul type="disc"><li><s><s><s><s><s>A query expression with a single <b>from</b> clause, an <b>orderby</b> clause, and a <b>group</b> clause</s></s></s></s></s></li>
</ul><s><s><s><s><s> </s></s></s></s></s><pre class="code"><s><s><s><s><s>from x in e orderby k<sub>1</sub> , k<sub>2</sub> ... group v by g</s></s></s></s></s></pre><s><s><s><s><s> </s></s></s></s></s><ul type="disc"><li><s><s><s><s><s>is translated into</s></s></s></s></s></li>
</ul><s><s><s><s><s> </s></s></s></s></s><pre class="code"><s><s><s><s><s>( e ) . OrderBy ( x => k<sub>1</sub> ) . ThenBy ( x => k<sub>2</sub> ) ...
. GroupBy ( x => g , x => v )</s></s></s></s></s></pre><s><s><s><s><s> </s></s></s></s></s><ul type="disc"><li><s><s><s><s><s>except when v is the identifier x, the translation is</s></s></s></s></s></li>
</ul><s><s><s><s><s> </s></s></s></s></s><pre class="code"><s><s><s><s><s>( e ) . OrderBy ( x => k<sub>1</sub> ) . ThenBy ( x => k<sub>2</sub> ) ... . GroupBy ( x => g )</s></s></s></s></s></pre><s><s><s><s><s> </s></s></s></s></s><h2 class="dtH1"><s _moz-rs-heading=""><s _moz-rs-heading=""><s _moz-rs-heading=""><s _moz-rs-heading=""><s _moz-rs-heading=""><a href="" name="cs3spec_topic9"><!----></a>Expression Trees</s></s></s></s></s></h2><s><s><s><s><s> </s></s></s></s></s><s><s><s><s><s>Expression trees permit lambda expressions to be represented as data structures instead of executable code. A lambda expression that is convertible to a delegate type <b>D</b> is also convertible to an expression tree of type <b>System.Query.Expression<d></d></b>. Whereas the conversion of a lambda expression to a delegate type causes executable code to be generated and referenced by a delegate, conversion to an expression tree type causes code that creates an expression tree instance to be emitted. Expression trees are efficient in-memory data representations of lambda expressions and make the structure of the expression transparent and explicit.</s></s></s></s></s><br />
<s><s><s><s><s> </s></s></s></s></s><s><s><s><s><s>The following example represents a lambda expression both as executable code and as an expression tree. Because a conversion exists to <b>Func<int,int></int,int></b>, a conversion also exists to <b>Expression<func><int,int>></int,int></func></b>.</s></s></s></s></s><br />
<s><s><s><s><s> </s></s></s></s></s><pre class="code"><s><s><s><s><s>Func<int,int> f = x => x + 1; // Code
Expression<func><int,int>> e = x => x + 1; // Data</int,int></func></int,int></s></s></s></s></s></pre><s><s><s><s><s> </s></s></s></s></s><s><s><s><s><s>Following these assignments, the delegate <b>f</b> references a method that returns <b>x</b> <b>+</b> <b>1</b>, and the expression tree <b>e</b> references a data structure that describes the expression <b>x</b> <b>+</b> <b>1</b>.</s></s></s></s></s>Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-7129929778341648750.post-23751168397057167952010-01-30T19:39:00.005+05:302010-01-30T19:39:51.659+05:30Implicitly Typed ArraysThe syntax of array creation expressions (§7.5.10.2) is extended to support implicitly typed array creation expressions:<br />
<pre class="code">array-creation-expression:
...
new [ ] array-initializer</pre>In an implicitly typed array creation expression, the type of the array instance is inferred from the elements specified in the array initializer. Specifically, the set formed by the types of the expressions in the array initializer must contain exactly one type to which each type in the set is implicitly convertible, and if that type is not the null type, an array of that type is created. If exactly one type cannot be inferred, or if the inferred type is the null type, a compile-time error occurs.<br />
The following are examples of implicitly typed array creation expressions:<br />
<pre class="code">var a = new[] { 1, 10, 100, 1000 }; // int[]
var b = new[] { 1, 1.5, 2, 2.5 }; // double[]
var c = new[] { "hello", null, "world" }; // string[]
var d = new[] { 1, "one", 2, "two" }; // Error</pre>The last expression causes a compile-time error because neither <b>int</b> nor <b>string</b> is implicitly convertible to the other. An explicitly typed array creation expression must be used in this case, for example specifying the type to be <b>object[]</b>. Alternatively, one of the elements can be cast to a common base type, which would then become the inferred element type.<br />
Implicitly typed array creation expressions can be combined with anonymous object initializers to create anonymously typed data structures. For example:<br />
<pre class="code">var contacts = new[] {
new {
Name = "Chris Smith",
PhoneNumbers = new[] { "206-555-0101", "425-882-8080" }
},
new {
Name = "Bob Harris",
PhoneNumbers = new[] { "650-555-0199" }
}
};</pre>Unknownnoreply@blogger.com1tag:blogger.com,1999:blog-7129929778341648750.post-2461836454663348062010-01-30T19:39:00.002+05:302010-01-30T19:39:26.859+05:30Anonymous TypesC# 3.0 permits the <b>new</b> operator to be used with an anonymous object initializer to create an object of an anonymous type.<br />
<pre class="code">primary-no-array-creation-expression:
...
anonymous-object-creation-expression
anonymous-object-creation-expression:
new anonymous-object-initializer
anonymous-object-initializer:
{ member-declarator-list<sub>opt</sub> }
{ member-declarator-list , }
member-declarator-list:
member-declarator
member-declarator-list , member-declarator
member-declarator:
simple-name
member-access
identifier = expression</pre>An anonymous object initializer declares an anonymous type and returns an instance of that type. An anonymous type is a nameless class type that inherits directly from <b>object</b>. The members of an anonymous type are a sequence of read/write properties inferred from the object initializer(s) used to create instances of the type. Specifically, an anonymous object initializer of the form<br />
<pre class="code">new { p<sub>1</sub> = e<sub>1</sub> , p<sub>2</sub> = e<sub>2</sub> , ... p<sub>n</sub> = e<sub>n</sub> }</pre>declares an anonymous type of the form<br />
<pre class="code">class __Anonymous1
{
private T<sub>1</sub> f<sub>1</sub> ;
private T<sub>2</sub> f<sub>2</sub> ;
...
private T<sub>n</sub> f<sub>n</sub> ;
public T<sub>1</sub> p<sub>1</sub> { get { return f<sub>1</sub> ; } set { f<sub>1</sub> = value ; } }
public T<sub>2</sub> p<sub>2</sub> { get { return f<sub>2</sub> ; } set { f<sub>2</sub> = value ; } }
...
public T<sub>1</sub> p<sub>1</sub> { get { return f<sub>1</sub> ; } set { f<sub>1</sub> = value ; } }
}</pre>where each T<sub>x</sub> is the type of the corresponding expression e<sub>x</sub>. It is a compile-time error for an expression in an anonymous object initializer to be of the null type.<br />
The name of an anonymous type is automatically generated by the compiler and cannot be referenced in program text.<br />
Within the same program, two anonymous object initializers that specify a sequence of properties of the same names and types in the same order will produce instances of the same anonymous type. (This definition includes the order of the properties because it is observable and material in certain circumstances, such as reflection.)<br />
In the example<br />
<pre class="code">var p1 = new { Name = "Lawnmower", Price = 495.00 };
var p2 = new { Name = "Shovel", Price = 26.95 };
p1 = p2;</pre>the assignment on the last line is permitted because <b>p1</b> and <b>p2</b> are of the same anonymous type.<br />
A member declarator can be abbreviated to a simple name (§7.5.2) or a member access (§7.5.4). This is called a <b>projection initializer</b> and is shorthand for a declaration of and assignment to a property with the same name. Specifically, member declarators of the forms<br />
<pre class="code">identifier expr . identifier</pre>are precisely equivalent to the following, respectively:<br />
<pre class="code">identifer = identifier identifier = expr . identifier</pre>Thus, in a projection initializer the identifier selects both the value and the field or property to which the value is assigned. Intuitively, a projection initializer projects not just a value, but also the name of the value.<br />
<h2 class="dtH1"><a href="" name="cs3spec_topic7"><!----></a></h2>Unknownnoreply@blogger.com0