Microsoft launches .NET Foundation to foster The .NET Open Source Ecosystem ,you can read more on the same from below link.

http://techcrunch.com/2014/04/03/microsoft-launches-net-foundation-to-foster-the-net-open-source-ecosystem/

For a fresher level interview,it’s a very common question to ask about the difference between string and stringbuilder.I am sure,most of you know the one line answer for that.But when it comes to an experienced level,you need to really understand how exactly the string builder works and how the string builder object allocates memory.

Here is a good read on this topic.

http://msdn.microsoft.com/en-us/library/system.text.stringbuilder.aspx#HowWorks

An interesting question I faced for an interview at Philips was,can we use VB.net class within a .net project that uses C# ? Answer is Yes ,but when the interviewer asked me if there could be any possible issues,I was unable explain it properly because I have not tried it practically :) Here is a nice post about this with practical example explanation,you can read through the same

http://brijbhushan.net/2014/01/29/how-to-use-two-different-languages-in-a-net-project/

 

Convert Xsd file to a c# class

Posted: October 17, 2013 in Uncategorized
Tags: ,

Sharing a small tip on how an xsd file can be converted to a c# class.I know many of you din’t even know that we have a way to convert xsd to class :) If so,this is for you.

Steps :

1.Open Visual Studio Command Prompt
2.Browse to the directory which contains your xsd
3. Type the below command and hit enter

   xsd /c MyXSD.xsd

C# class will be generated in same directory which has your xsd.

It’s been quite some time since I shared anything and today I am going to share something about Enums. When you use Enums, it makes your code easily understandable.

Lets take a small Enum as example

public enum Status

        {

            New = 1,

            Active = 2,

            Inactive = 3

        }

  If you want to change an Enum into array of strings, you can use the Enum class GetNames method:

string[] Status = Enum.GetNames(typeof(Status));

You can bind the output from GetNames to a control to get the list of the names in the Enum displayed in UI.

There is a common scenario where we want to convert  a string containing one of the names in an Enum into the Enum item itself when you are reading the data from database.

Parse method below does that job,but throws an exception “System.ArgumentException was unhandled” if the string value you are passing to Parse isn’t an item in the Enum.

string custStatus = “Test”;

Status sts = (Status)Enum.Parse(typeof(Status), custStatus);

This exception can be avoided if you use the Enum’s TryParse method.

  Status stat;

    if (Enum.TryParse<Status>(custStatus, true, out stat))

    {

        Console.WriteLine(“Status Found: “+stat.ToString());

    }

    else

    {

        Console.WriteLine(“Status not found!”);

    }

An even better solution  is to use the Enum’s IsDefined method to see if the item exists before you try to get it .

if (Enum.IsDefined(typeof(Status), custStatus))

            {

                Status sts = (Status)Enum.Parse(typeof(Status), custStatus);

            }

            else

            {

                Console.WriteLine(“Status not found!”);

            }

 

Hope you enjoyed reading this.

Some people are really fast in creating properties and you might have thought how they do it.This tip is for you if you did not know it before :)

You can type “prop” and then press tab twice, that will generate the following.

public int MyProperty
{
get;
set;
}

You can also get the full property by typing “propfull” and tabbing twice, that would generate the field and the full property.

private int myVar;

public int MyProperty
{
get
{
return myVar;
}
set
{
myVar = value;
}
}

Fiddler stopped capturing SoapUI traffic

Posted: November 20, 2012 in SoapUI
Tags: ,

One of my wcf services was giving a failure and I wanted to badly capture the xml request it passes internally to another wcf service it calls.
It was really irritating when I realized that my fiddler has stopped somehow capturing the details of request and response.It took some time,still figured out how to solve & I thought I must share this here.

Steps to follow,open SoapUI,File –> Preferences –> Proxy Settings window . Add setting as shown below.

 
If you think why we added Port No. 8888 in the proxy settings of soapUI,it is because Fiddler listens to port no. 8888 by default.

Now resubmit your request in SoapUI,you see that fiddler has started capturing the traffic.