I got it from my colleague and found it very useful and thought of sharing it: Character Description \ Marks the next character as either a special character or escapes a literal. For example, “n” matches the character “n”. “\n” matches a newline character. The sequence “\\” matches “\” and “\(” matches “(“. Note: double [...]
Tag: C#
November 1, 2012
October 19, 2012
Generate C# classes from XML or XSD
XSD.Exe is the tool to go ahead. C:\temp>xsd test.xml Microsoft (R) Xml Schemas/DataTypes support utility [Microsoft (R) .NET Framework, Version 4.0.30319.1] Copyright (C) Microsoft Corporation. All rights reserved. Writing file ‘D:\temp\test.xsd’. C:\temp>xsd test.xsd /classes Microsoft (R) Xml Schemas/DataTypes support utility [Microsoft (R) .NET Framework, Version 4.0.30319.1] Copyright (C) Microsoft Corporation. All rights reserved. Writing [...]
September 18, 2012
JSON to .Net Objects – Expecting state ‘Element’.. Encountered ‘Text’ with name ”, namespace ”.
The tricky error while deserializing the JSON stream to corresponding Dot Net object(s) is very annoying. I spent few hours searching for a viable solution and found the funny issue in what we receive in JSON response. Usually, it happens when the response contains some loose text i.e. no Nodes specified in the JSON format [...]
November 27, 2010
How to convert from IEnumerable to EntitySet to get Entity back in action
One way of achieving is to use what most google search results find on web i.e. public static EntitySet<T> ToEntitySet<T> (this IEnumerable<T> source) where T : class { var es = new EntitySet<T> (); es.AddRange (source); return es; } Then you could write your query as follows: var questions = [...]
February 18, 2010
Create Word Document with Hyperlinks in it with C# code
First of all you need to add reference to COM library in project. Add reference to Microsoft word 11.0 word library under COM reference tab Add this in the code behind “using” section using Microsoft.Office.Interop.Word; private void CreateWordDocument() { // create annonymous object to be referenced throughout object oMissingReference = System.Reflection.Missing.Value; object Visible=true; // define [...]
February 16, 2010
Calling constructor inside constructor in C#
To call one C# constructor from another, before the body of the constructor, use either: : base (parameters) to call a constructor in the base class; or: : this (parameters) to call a constructor in this class. The following examples illustrate how to call one constructor from another. public class myPopUp { public myPopUp(int [...]
