If you are running .Net framework 4 and want to get IP address of local machine using C# code then just make following function which will return you local machine ip address.
private string GetLocalIP()
IPAddress IPAddList = Dns.GetHostEntry(Dns.GetHostName()).AddressList;
return IPAddList[IPAddList.Length - 2].ToString();
In previous versions of .net it was [IPAddList.Length – 1] to be return so make change in your code according to your development framework.