Archive for February 2010

Free ebook - Beginning Visual Basic 2010

What better way to get started with Visual Basic than with this essential Wrox beginner’s guide?

Beginning Microsoft Visual Basic 2010 not only shows you how to write Windows applications, Web applications with ASP.NET, and Windows mobile and embedded CE apps with Visual Basic 2010, but you’ll also get a thorough grounding in the basic nuts-and-bolts of writing good code.A focused, step-by-step approach to Visual Basic for new programmers.

You’ll be exposed to the very latest VB tools and techniques with coverage of both the Visual Studio 2010 and .NET 4 releases. Plus, the book walks you step-by-step through tasks, as you gradually master this exciting new release of Microsoft’s popular and important programming language.


  • Microsoft’s Visual Basic is a frequent first language for new programmers; this clear, focused book walks you through the basics and gets you quickly productive in Visual Basic

  • Features in-depth coverage of the Visual Studio 2010 and .NET 4 releases, so you’ll be learning the very latest VB tools and techniques

  • Discusses flow control, data structure, Windows applications, dialog boxes, menus, error handing and debugging, and objects and object oriented techniques

  • Covers class libraries, Windows Forms, graphics programming, accessing databases, Web programming with ASP.NET and Visual Basic, data access, SQL Server, ADO.NET, and XML

Free Download Links
1. Hotfile Link
http://hotfile.com/.../Visual.Basic.2010.rar.html

2. Uploading Link
http://uploading.com/files/get/25267b23/

Source : downarchive.com

If you like this post, please add your comments and 'A thanks' would be nice.

Free ebook - Beginning Visual Basic 2010

What better way to get started with Visual Basic than with this essential Wrox beginner’s guide?

Beginning Microsoft Visual Basic 2010 not only shows you how to write Windows applications, Web applications with ASP.NET, and Windows mobile and embedded CE apps with Visual Basic 2010, but you’ll also get a thorough grounding in the basic nuts-and-bolts of writing good code.A focused, step-by-step approach to Visual Basic for new programmers.

You’ll be exposed to the very latest VB tools and techniques with coverage of both the Visual Studio 2010 and .NET 4 releases. Plus, the book walks you step-by-step through tasks, as you gradually master this exciting new release of Microsoft’s popular and important programming language.


  • Microsoft’s Visual Basic is a frequent first language for new programmers; this clear, focused book walks you through the basics and gets you quickly productive in Visual Basic

  • Features in-depth coverage of the Visual Studio 2010 and .NET 4 releases, so you’ll be learning the very latest VB tools and techniques

  • Discusses flow control, data structure, Windows applications, dialog boxes, menus, error handing and debugging, and objects and object oriented techniques

  • Covers class libraries, Windows Forms, graphics programming, accessing databases, Web programming with ASP.NET and Visual Basic, data access, SQL Server, ADO.NET, and XML

Free Download Links
1. Hotfile Link
http://hotfile.com/.../Visual.Basic.2010.rar.html

2. Uploading Link
http://uploading.com/files/get/25267b23/

Source : downarchive.com

If you like this post, please add your comments and 'A thanks' would be nice.

Free ebook - Beginning Visual Basic 2010

What better way to get started with Visual Basic than with this essential Wrox beginner’s guide?

Beginning Microsoft Visual Basic 2010 not only shows you how to write Windows applications, Web applications with ASP.NET, and Windows mobile and embedded CE apps with Visual Basic 2010, but you’ll also get a thorough grounding in the basic nuts-and-bolts of writing good code.A focused, step-by-step approach to Visual Basic for new programmers.

You’ll be exposed to the very latest VB tools and techniques with coverage of both the Visual Studio 2010 and .NET 4 releases. Plus, the book walks you step-by-step through tasks, as you gradually master this exciting new release of Microsoft’s popular and important programming language.


  • Microsoft’s Visual Basic is a frequent first language for new programmers; this clear, focused book walks you through the basics and gets you quickly productive in Visual Basic

  • Features in-depth coverage of the Visual Studio 2010 and .NET 4 releases, so you’ll be learning the very latest VB tools and techniques

  • Discusses flow control, data structure, Windows applications, dialog boxes, menus, error handing and debugging, and objects and object oriented techniques

  • Covers class libraries, Windows Forms, graphics programming, accessing databases, Web programming with ASP.NET and Visual Basic, data access, SQL Server, ADO.NET, and XML

Free Download Links
1. Hotfile Link
http://hotfile.com/.../Visual.Basic.2010.rar.html

2. Uploading Link
http://uploading.com/files/get/25267b23/

Source : downarchive.com

If you like this post, please add your comments and 'A thanks' would be nice.

Free ebook - SAMS C# 4.0 How-To

Need fast, robust, efficient code solutions for Microsoft C# 4.0? This book delivers exactly what you’re looking for. You’ll find more than 200 solutions, best-practice techniques, and tested code samples for everything from classes to exceptions, networking to XML, LINQ to Silverlight.

Completely up-to-date, this book fully reflects major language enhancements introduced with the new C# 4.0 and .NET 4.0. When time is of the essence, turn here first: Get answers you can trust and code you can use, right now!

Beginning with the language essentials and moving on to solving common problems using the .NET Framework, C# 4.0 How-To addresses a wide range of general programming problems and algorithms.

Along the way is clear, concise coverage of a broad spectrum of C# techniques that will help developers of all levels become more proficient with C# and the most popular .NET tools.


Product Details
  • Paperback: 672 pages
  • Publisher: Sams; 1 edition (March 19, 2010)
  • Language: English
  • ISBN-10: 0672330636
  • ISBN-13: 978-0672330636

Free Download Links :

1. Hotfile Link
http://hotfile.com/.../Sams.CSharp.4.0.How.To.Feb.2010.rar.html

If you like this post, please add your comments and 'A thanks' would be nice.

Free ebook - SAMS C# 4.0 How-To

Need fast, robust, efficient code solutions for Microsoft C# 4.0? This book delivers exactly what you’re looking for. You’ll find more than 200 solutions, best-practice techniques, and tested code samples for everything from classes to exceptions, networking to XML, LINQ to Silverlight.

Completely up-to-date, this book fully reflects major language enhancements introduced with the new C# 4.0 and .NET 4.0. When time is of the essence, turn here first: Get answers you can trust and code you can use, right now!

Beginning with the language essentials and moving on to solving common problems using the .NET Framework, C# 4.0 How-To addresses a wide range of general programming problems and algorithms.

Along the way is clear, concise coverage of a broad spectrum of C# techniques that will help developers of all levels become more proficient with C# and the most popular .NET tools.


Product Details
  • Paperback: 672 pages
  • Publisher: Sams; 1 edition (March 19, 2010)
  • Language: English
  • ISBN-10: 0672330636
  • ISBN-13: 978-0672330636

Free Download Links :

1. Hotfile Link
http://hotfile.com/.../Sams.CSharp.4.0.How.To.Feb.2010.rar.html

If you like this post, please add your comments and 'A thanks' would be nice.

Free ebook - SAMS C# 4.0 How-To

Need fast, robust, efficient code solutions for Microsoft C# 4.0? This book delivers exactly what you’re looking for. You’ll find more than 200 solutions, best-practice techniques, and tested code samples for everything from classes to exceptions, networking to XML, LINQ to Silverlight.

Completely up-to-date, this book fully reflects major language enhancements introduced with the new C# 4.0 and .NET 4.0. When time is of the essence, turn here first: Get answers you can trust and code you can use, right now!

Beginning with the language essentials and moving on to solving common problems using the .NET Framework, C# 4.0 How-To addresses a wide range of general programming problems and algorithms.

Along the way is clear, concise coverage of a broad spectrum of C# techniques that will help developers of all levels become more proficient with C# and the most popular .NET tools.


Product Details
  • Paperback: 672 pages
  • Publisher: Sams; 1 edition (March 19, 2010)
  • Language: English
  • ISBN-10: 0672330636
  • ISBN-13: 978-0672330636

Free Download Links :

1. Hotfile Link
http://hotfile.com/.../Sams.CSharp.4.0.How.To.Feb.2010.rar.html

If you like this post, please add your comments and 'A thanks' would be nice.

Free ebook - CLR via C# 3rd Edition

Dig deep and master the intricacies of the common language runtime (CLR) and the .NET Framework 4.0. Written by a highly regarded programming expert and consultant to the Microsoft(R) .NET team, this guide is ideal for developers building any kind of application-including Microsoft(R) ASP.NET, Windows(R) Forms, Microsoft(R) SQL Server(R), Web services, and console applications.

You’ll get hands-on instruction and extensive C# code samples to help you tackle the tough topics and develop high-performance applications.


Product Details

  • Paperback: 896 pages
  • Publisher: Microsoft Press; 3 edition (February 15, 2010)
  • Language: English
  • ISBN-10: 0735627045
  • ISBN-13: 978-0735627048

Free Download Links :

1. Megaupload Link
http://www.megaupload.com/?d=JS3CUIUS


2. Rapidshare Link
http://rapidshare.com/...Csharp.3rd.Edition.Feb.2010.rar


3. Hotfile Link
http://hotfile.com/...Csharp.3rd.Edition.Feb.2010.rar.html


If you like this post, please add your comments and 'A thanks' would be nice.

Free ebook - CLR via C# 3rd Edition

Dig deep and master the intricacies of the common language runtime (CLR) and the .NET Framework 4.0. Written by a highly regarded programming expert and consultant to the Microsoft(R) .NET team, this guide is ideal for developers building any kind of application-including Microsoft(R) ASP.NET, Windows(R) Forms, Microsoft(R) SQL Server(R), Web services, and console applications.

You’ll get hands-on instruction and extensive C# code samples to help you tackle the tough topics and develop high-performance applications.


Product Details

  • Paperback: 896 pages
  • Publisher: Microsoft Press; 3 edition (February 15, 2010)
  • Language: English
  • ISBN-10: 0735627045
  • ISBN-13: 978-0735627048

Free Download Links :

1. Megaupload Link
http://www.megaupload.com/?d=JS3CUIUS


2. Rapidshare Link
http://rapidshare.com/...Csharp.3rd.Edition.Feb.2010.rar


3. Hotfile Link
http://hotfile.com/...Csharp.3rd.Edition.Feb.2010.rar.html


If you like this post, please add your comments and 'A thanks' would be nice.

Free ebook - CLR via C# 3rd Edition

Dig deep and master the intricacies of the common language runtime (CLR) and the .NET Framework 4.0. Written by a highly regarded programming expert and consultant to the Microsoft(R) .NET team, this guide is ideal for developers building any kind of application-including Microsoft(R) ASP.NET, Windows(R) Forms, Microsoft(R) SQL Server(R), Web services, and console applications.

You’ll get hands-on instruction and extensive C# code samples to help you tackle the tough topics and develop high-performance applications.


Product Details

  • Paperback: 896 pages
  • Publisher: Microsoft Press; 3 edition (February 15, 2010)
  • Language: English
  • ISBN-10: 0735627045
  • ISBN-13: 978-0735627048

Free Download Links :

1. Megaupload Link
http://www.megaupload.com/?d=JS3CUIUS


2. Rapidshare Link
http://rapidshare.com/...Csharp.3rd.Edition.Feb.2010.rar


3. Hotfile Link
http://hotfile.com/...Csharp.3rd.Edition.Feb.2010.rar.html


If you like this post, please add your comments and 'A thanks' would be nice.

.NET 4 String Function to Check for Empty Strings

Question is...
How to Check an Empty Strings or not in ASP.NET 4.0?

How many times have you written code similar to this?

string firstName = FirstName.Text.Trim();

if (!string.IsNullOrEmpty(firstName))
{
// do something
}

// or

if (someParam == null || string.IsNullOrEmpty(someParam.Trim())
throw new ArgumentException("Empty string", "someParam");

// do something

A nice little time-saver for those guard functions is now included in .NET 4 - the IsNullOrWhiteSpace function

if (!string.IsNullOrWhiteSpace(FirstName.Text))
{
// do something
}

IsNullOrWhiteSpace checks for null, empty or whitespace characters.

Sure, it’s a little thing, but it’s nice to have it in there, especially considering we get all sorts of nice new little things, and the client framework install is still smaller than it was in .NET 3.5

.NET 4 String Function to Check for Empty Strings

Question is...
How to Check an Empty Strings or not in ASP.NET 4.0?

How many times have you written code similar to this?

string firstName = FirstName.Text.Trim();

if (!string.IsNullOrEmpty(firstName))
{
// do something
}

// or

if (someParam == null || string.IsNullOrEmpty(someParam.Trim())
throw new ArgumentException("Empty string", "someParam");

// do something

A nice little time-saver for those guard functions is now included in .NET 4 - the IsNullOrWhiteSpace function

if (!string.IsNullOrWhiteSpace(FirstName.Text))
{
// do something
}

IsNullOrWhiteSpace checks for null, empty or whitespace characters.

Sure, it’s a little thing, but it’s nice to have it in there, especially considering we get all sorts of nice new little things, and the client framework install is still smaller than it was in .NET 3.5

.NET 4 String Function to Check for Empty Strings

Question is...
How to Check an Empty Strings or not in ASP.NET 4.0?

How many times have you written code similar to this?

string firstName = FirstName.Text.Trim();

if (!string.IsNullOrEmpty(firstName))
{
// do something
}

// or

if (someParam == null || string.IsNullOrEmpty(someParam.Trim())
throw new ArgumentException("Empty string", "someParam");

// do something

A nice little time-saver for those guard functions is now included in .NET 4 - the IsNullOrWhiteSpace function

if (!string.IsNullOrWhiteSpace(FirstName.Text))
{
// do something
}

IsNullOrWhiteSpace checks for null, empty or whitespace characters.

Sure, it’s a little thing, but it’s nice to have it in there, especially considering we get all sorts of nice new little things, and the client framework install is still smaller than it was in .NET 3.5

Free ebook - Accelerated C# 2010

C# 2010 offers powerful new features, and this book is the fastest path to mastering them - and the rest of C# - for both experienced C# programmers moving to C# 2010 and programmers moving to C# from another object-oriented language.

Many books introduce C#, but very few also explain how to use it optimally with the .NET Common Language Runtime (CLR).

This book teaches both core C# language concepts and how to wisely employ C# idioms and object-oriented design patterns to exploit the power of C# and the CLR.

Product Details
  • Paperback: 450 pages
  • Publisher: Apress; 1 edition (February 1, 2010)
  • Language: English
  • ISBN-10: 1430225378
  • ISBN-13: 978-1430225379

Free Download Links :

1. Hotfile Link
http://hotfile.com/.../Apress.Accelerated.CSharp.2010.Jan.2010.rar.html

2. Depositfiles Link
http://depositfiles.com/en/files/z5irsz0vc

3. Turbobit Link
http://www.turbobit.net/qwwwwn1cr5bu.html

4. Mediafire Link
http://www.mediafire.com/?zdimymencjz

5.Megaupload Link
http://www.megaupload.com/?d=DSBGXTDC

6. Rapidshare Link
http://rapidshare.com/files/337300455/BR-1663-ACs10.rar

If you like this post, please add your comments and 'A thanks' would be nice.

Free ebook - Accelerated C# 2010

C# 2010 offers powerful new features, and this book is the fastest path to mastering them - and the rest of C# - for both experienced C# programmers moving to C# 2010 and programmers moving to C# from another object-oriented language.

Many books introduce C#, but very few also explain how to use it optimally with the .NET Common Language Runtime (CLR).

This book teaches both core C# language concepts and how to wisely employ C# idioms and object-oriented design patterns to exploit the power of C# and the CLR.

Product Details
  • Paperback: 450 pages
  • Publisher: Apress; 1 edition (February 1, 2010)
  • Language: English
  • ISBN-10: 1430225378
  • ISBN-13: 978-1430225379

Free Download Links :

1. Hotfile Link
http://hotfile.com/.../Apress.Accelerated.CSharp.2010.Jan.2010.rar.html

2. Depositfiles Link
http://depositfiles.com/en/files/z5irsz0vc

3. Turbobit Link
http://www.turbobit.net/qwwwwn1cr5bu.html

4. Mediafire Link
http://www.mediafire.com/?zdimymencjz

5.Megaupload Link
http://www.megaupload.com/?d=DSBGXTDC

6. Rapidshare Link
http://rapidshare.com/files/337300455/BR-1663-ACs10.rar

If you like this post, please add your comments and 'A thanks' would be nice.

Free ebook - Accelerated C# 2010

C# 2010 offers powerful new features, and this book is the fastest path to mastering them - and the rest of C# - for both experienced C# programmers moving to C# 2010 and programmers moving to C# from another object-oriented language.

Many books introduce C#, but very few also explain how to use it optimally with the .NET Common Language Runtime (CLR).

This book teaches both core C# language concepts and how to wisely employ C# idioms and object-oriented design patterns to exploit the power of C# and the CLR.

Product Details
  • Paperback: 450 pages
  • Publisher: Apress; 1 edition (February 1, 2010)
  • Language: English
  • ISBN-10: 1430225378
  • ISBN-13: 978-1430225379

Free Download Links :

1. Hotfile Link
http://hotfile.com/.../Apress.Accelerated.CSharp.2010.Jan.2010.rar.html

2. Depositfiles Link
http://depositfiles.com/en/files/z5irsz0vc

3. Turbobit Link
http://www.turbobit.net/qwwwwn1cr5bu.html

4. Mediafire Link
http://www.mediafire.com/?zdimymencjz

5.Megaupload Link
http://www.megaupload.com/?d=DSBGXTDC

6. Rapidshare Link
http://rapidshare.com/files/337300455/BR-1663-ACs10.rar

If you like this post, please add your comments and 'A thanks' would be nice.

Convert a DataTable to a List<> using C#

Question is...
Convert a DataTable to a List<> using C#

To convert a DataTable to a List<> in .NET 2.0.

Here’s the code to do so:


// Assuming there is a DataTable called dt
List<DataRow> drlist = new List<DataRow>();

foreach (DataRow row in dt.Rows)
{
drlist.Add((DataRow)row);
}

Please note that this is just a prototype and may not cover all scenarios.

Note: I have not tested this but in .NET 3.5, you should be able to do this:

List<DataRow> drlist = dt.AsEnumerable().ToList();

Convert a DataTable to a List<> using C#

Question is...
Convert a DataTable to a List<> using C#

To convert a DataTable to a List<> in .NET 2.0.

Here’s the code to do so:


// Assuming there is a DataTable called dt
List<DataRow> drlist = new List<DataRow>();

foreach (DataRow row in dt.Rows)
{
drlist.Add((DataRow)row);
}

Please note that this is just a prototype and may not cover all scenarios.

Note: I have not tested this but in .NET 3.5, you should be able to do this:

List<DataRow> drlist = dt.AsEnumerable().ToList();

Convert a DataTable to a List<> using C#

Question is...
Convert a DataTable to a List<> using C#

To convert a DataTable to a List<> in .NET 2.0.

Here’s the code to do so:


// Assuming there is a DataTable called dt
List<DataRow> drlist = new List<DataRow>();

foreach (DataRow row in dt.Rows)
{
drlist.Add((DataRow)row);
}

Please note that this is just a prototype and may not cover all scenarios.

Note: I have not tested this but in .NET 3.5, you should be able to do this:

List<DataRow> drlist = dt.AsEnumerable().ToList();

Simplest way to Programmatically ShutDown or Restart your System using C#

Question is...
Simplest way to Programmatically ShutDown or Restart your System using C#

One of the ways to ShutDown or Restart your system is to use WMI (Windows Management Interface). However it does require you to write a few lines of code.

I have found that the simplest way to ShutDown or Restart your computer is to use the Process class in the System.Diagnostics namespace. Here’s an example:


private void btnShutDown_Click(object sender, EventArgs e)
{
Process.Start("shutdown", "-s -f -t 0");
}

private void btnRestart_Click(object sender, EventArgs e)
{
Process.Start("shutdown", "-r -f -t 0");
}

Simplest way to Programmatically ShutDown or Restart your System using C#

Question is...
Simplest way to Programmatically ShutDown or Restart your System using C#

One of the ways to ShutDown or Restart your system is to use WMI (Windows Management Interface). However it does require you to write a few lines of code.

I have found that the simplest way to ShutDown or Restart your computer is to use the Process class in the System.Diagnostics namespace. Here’s an example:


private void btnShutDown_Click(object sender, EventArgs e)
{
Process.Start("shutdown", "-s -f -t 0");
}

private void btnRestart_Click(object sender, EventArgs e)
{
Process.Start("shutdown", "-r -f -t 0");
}

Simplest way to Programmatically ShutDown or Restart your System using C#

Question is...
Simplest way to Programmatically ShutDown or Restart your System using C#

One of the ways to ShutDown or Restart your system is to use WMI (Windows Management Interface). However it does require you to write a few lines of code.

I have found that the simplest way to ShutDown or Restart your computer is to use the Process class in the System.Diagnostics namespace. Here’s an example:


private void btnShutDown_Click(object sender, EventArgs e)
{
Process.Start("shutdown", "-s -f -t 0");
}

private void btnRestart_Click(object sender, EventArgs e)
{
Process.Start("shutdown", "-r -f -t 0");
}

Convert a String Array to a Decimal Array using C#

Question is...
Convert a String Array to a Decimal Array using C#

The Array.ConvertAll() method is a very useful method to convert an array of one type to an array of another type.

Here’s how to use ConvertAll() to convert a String[] to Decimal[]


static void Main(string[] args)
{
string[] strArray = new string[] { "1164", "2213" };

decimal d;
decimal[] d1;

// Check if string can be converted to decimal equivalent
if (strArray.All(number => Decimal.TryParse(number, out d)))
{
d1 = Array.ConvertAll<string, decimal>(strArray, Convert.ToDecimal);
}
}

The first step is to use Enumerable.All(TSource) to determine whether all the elements in a sequence satisfy a condition, in our case, if all the elements of the array can be converted to its decimal equivalent.

Once this can be done, we use ConvertAll() to convert an array of string to an array of decimal.

Convert a String Array to a Decimal Array using C#

Question is...
Convert a String Array to a Decimal Array using C#

The Array.ConvertAll() method is a very useful method to convert an array of one type to an array of another type.

Here’s how to use ConvertAll() to convert a String[] to Decimal[]


static void Main(string[] args)
{
string[] strArray = new string[] { "1164", "2213" };

decimal d;
decimal[] d1;

// Check if string can be converted to decimal equivalent
if (strArray.All(number => Decimal.TryParse(number, out d)))
{
d1 = Array.ConvertAll<string, decimal>(strArray, Convert.ToDecimal);
}
}

The first step is to use Enumerable.All(TSource) to determine whether all the elements in a sequence satisfy a condition, in our case, if all the elements of the array can be converted to its decimal equivalent.

Once this can be done, we use ConvertAll() to convert an array of string to an array of decimal.

Convert a String Array to a Decimal Array using C#

Question is...
Convert a String Array to a Decimal Array using C#

The Array.ConvertAll() method is a very useful method to convert an array of one type to an array of another type.

Here’s how to use ConvertAll() to convert a String[] to Decimal[]


static void Main(string[] args)
{
string[] strArray = new string[] { "1164", "2213" };

decimal d;
decimal[] d1;

// Check if string can be converted to decimal equivalent
if (strArray.All(number => Decimal.TryParse(number, out d)))
{
d1 = Array.ConvertAll<string, decimal>(strArray, Convert.ToDecimal);
}
}

The first step is to use Enumerable.All(TSource) to determine whether all the elements in a sequence satisfy a condition, in our case, if all the elements of the array can be converted to its decimal equivalent.

Once this can be done, we use ConvertAll() to convert an array of string to an array of decimal.

Convert LowerCase and UpperCase to TitleCase in C#

Question is...
Convert LowerCase and UpperCase to TitleCase in C#

The String class has the ToLower() and the ToUpper() methods to convert a string to lowercase and uppercase respectively.

However when it comes to converting the string to TitleCase, the ToTitleCase() method of the TextInfo class comes very handy. Let me demonstrate this with an example:


class Program
{
static void Main(string[] args)
{
string strLow = "lower case";
string strT = CultureInfo.CurrentCulture.TextInfo.ToTitleCase(strLow);
Console.WriteLine("Lower Case to Title Case: " + strT);

string strCap = "UPPER CASE";
strT = CultureInfo.CurrentCulture.TextInfo.ToTitleCase(strCap.ToLower());
Console.WriteLine("Upper Case to Title Case: " + strT);
Console.ReadLine();
}
}

Make sure you import the System.Globalization namespace. As you can observe, we are using the CurrentCulture.TextInfo property to retrieve an instance of the TextInfo class based on the current culture.

Note:
As mentioned on the site, "this method does not currently provide proper casing to convert a word that is entirely uppercase, such as an acronym". This is the reason why we first convert strCap to lower case and then supply the lowercase string to ToTitleCase() in the following manner:

CultureInfo.CurrentCulture.TextInfo.ToTitleCase(strCap.ToLower());

Convert LowerCase and UpperCase to TitleCase in C#

Question is...
Convert LowerCase and UpperCase to TitleCase in C#

The String class has the ToLower() and the ToUpper() methods to convert a string to lowercase and uppercase respectively.

However when it comes to converting the string to TitleCase, the ToTitleCase() method of the TextInfo class comes very handy. Let me demonstrate this with an example:


class Program
{
static void Main(string[] args)
{
string strLow = "lower case";
string strT = CultureInfo.CurrentCulture.TextInfo.ToTitleCase(strLow);
Console.WriteLine("Lower Case to Title Case: " + strT);

string strCap = "UPPER CASE";
strT = CultureInfo.CurrentCulture.TextInfo.ToTitleCase(strCap.ToLower());
Console.WriteLine("Upper Case to Title Case: " + strT);
Console.ReadLine();
}
}

Make sure you import the System.Globalization namespace. As you can observe, we are using the CurrentCulture.TextInfo property to retrieve an instance of the TextInfo class based on the current culture.

Note:
As mentioned on the site, "this method does not currently provide proper casing to convert a word that is entirely uppercase, such as an acronym". This is the reason why we first convert strCap to lower case and then supply the lowercase string to ToTitleCase() in the following manner:

CultureInfo.CurrentCulture.TextInfo.ToTitleCase(strCap.ToLower());

Convert LowerCase and UpperCase to TitleCase in C#

Question is...
Convert LowerCase and UpperCase to TitleCase in C#

The String class has the ToLower() and the ToUpper() methods to convert a string to lowercase and uppercase respectively.

However when it comes to converting the string to TitleCase, the ToTitleCase() method of the TextInfo class comes very handy. Let me demonstrate this with an example:


class Program
{
static void Main(string[] args)
{
string strLow = "lower case";
string strT = CultureInfo.CurrentCulture.TextInfo.ToTitleCase(strLow);
Console.WriteLine("Lower Case to Title Case: " + strT);

string strCap = "UPPER CASE";
strT = CultureInfo.CurrentCulture.TextInfo.ToTitleCase(strCap.ToLower());
Console.WriteLine("Upper Case to Title Case: " + strT);
Console.ReadLine();
}
}

Make sure you import the System.Globalization namespace. As you can observe, we are using the CurrentCulture.TextInfo property to retrieve an instance of the TextInfo class based on the current culture.

Note:
As mentioned on the site, "this method does not currently provide proper casing to convert a word that is entirely uppercase, such as an acronym". This is the reason why we first convert strCap to lower case and then supply the lowercase string to ToTitleCase() in the following manner:

CultureInfo.CurrentCulture.TextInfo.ToTitleCase(strCap.ToLower());

Convert Enum to List<> using C#

Question is...
Convert Enum to List<> using C#

A user recently asked me how to convert an Enum to a List<>.

Here's the code to do so:

class Program
{
enum Days { Sat, Sun, Mon, Tue, Wed, Thu, Fri };

static void Main(string[] args)
{
Array arr = Enum.GetValues(typeof(Days));
List<string> lstDays = new List<string>(arr.Length);

for (int i = 0; i < arr.Length; i++)
{
lstDays.Add(arr.GetValue(i).ToString());
}
}
}

Convert Enum to List<> using C#

Question is...
Convert Enum to List<> using C#

A user recently asked me how to convert an Enum to a List<>.

Here's the code to do so:

class Program
{
enum Days { Sat, Sun, Mon, Tue, Wed, Thu, Fri };

static void Main(string[] args)
{
Array arr = Enum.GetValues(typeof(Days));
List<string> lstDays = new List<string>(arr.Length);

for (int i = 0; i < arr.Length; i++)
{
lstDays.Add(arr.GetValue(i).ToString());
}
}
}

Convert Enum to List<> using C#

Question is...
Convert Enum to List<> using C#

A user recently asked me how to convert an Enum to a List<>.

Here's the code to do so:

class Program
{
enum Days { Sat, Sun, Mon, Tue, Wed, Thu, Fri };

static void Main(string[] args)
{
Array arr = Enum.GetValues(typeof(Days));
List<string> lstDays = new List<string>(arr.Length);

for (int i = 0; i < arr.Length; i++)
{
lstDays.Add(arr.GetValue(i).ToString());
}
}
}

Find Out the Image Type without Checking its Extension using C#

Question is...
Find Out the Image Type without Checking its Extension using C#

My colleague called up with a query. His application accepted images to be uploaded to a central server. Later the application processed the images and separated them according to the Image Type. They determined the image type by checking the extension of the image uploaded –- a very common practice of detecting the image type.

The issue here was that some images which were actually gif’s were renamed as jpeg's and then uploaded, which led to faulty image processing. The requirement was to determine the correct image type in the simplest possible way even if the extension was renamed.

Here’s what I suggested:


try
{
Image imgUp = Image.FromFile(Server.MapPath("~/images/abc.jpg"));

if (imgUp.RawFormat.Equals(ImageFormat.Jpeg))
Response.Write("JPEG");

else if (imgUp.RawFormat.Equals(ImageFormat.Gif))
Response.Write("GIF");
}
catch (Exception ex)
{
}

Find Out the Image Type without Checking its Extension using C#

Question is...
Find Out the Image Type without Checking its Extension using C#

My colleague called up with a query. His application accepted images to be uploaded to a central server. Later the application processed the images and separated them according to the Image Type. They determined the image type by checking the extension of the image uploaded –- a very common practice of detecting the image type.

The issue here was that some images which were actually gif’s were renamed as jpeg's and then uploaded, which led to faulty image processing. The requirement was to determine the correct image type in the simplest possible way even if the extension was renamed.

Here’s what I suggested:


try
{
Image imgUp = Image.FromFile(Server.MapPath("~/images/abc.jpg"));

if (imgUp.RawFormat.Equals(ImageFormat.Jpeg))
Response.Write("JPEG");

else if (imgUp.RawFormat.Equals(ImageFormat.Gif))
Response.Write("GIF");
}
catch (Exception ex)
{
}

Find Out the Image Type without Checking its Extension using C#

Question is...
Find Out the Image Type without Checking its Extension using C#

My colleague called up with a query. His application accepted images to be uploaded to a central server. Later the application processed the images and separated them according to the Image Type. They determined the image type by checking the extension of the image uploaded –- a very common practice of detecting the image type.

The issue here was that some images which were actually gif’s were renamed as jpeg's and then uploaded, which led to faulty image processing. The requirement was to determine the correct image type in the simplest possible way even if the extension was renamed.

Here’s what I suggested:


try
{
Image imgUp = Image.FromFile(Server.MapPath("~/images/abc.jpg"));

if (imgUp.RawFormat.Equals(ImageFormat.Jpeg))
Response.Write("JPEG");

else if (imgUp.RawFormat.Equals(ImageFormat.Gif))
Response.Write("GIF");
}
catch (Exception ex)
{
}

How to calculate the CPU Usage Programmatically using C#

Question is...
How to calculate the CPU Usage Programmatically using C#

The PerformanceCounter class represents a WindowsNT performance counter component. To read from a performance counter, we first create an instance of the PerformanceCounter class supplying the CategoryName, CounterName, and InstanceName as parameters to the constructor and then call the NextValue() method to take a performance counter reading.

Import the namespaces System.Diagnostics and System.Threading.


static PerformanceCounter cpuUsage;
public static void Main(string[] args)
{
cpuUsage =
new PerformanceCounter("Processor", "% Processor Time", "_Total");

Console.WriteLine(cpuUsage.NextValue() + " %");
Thread.Sleep(1000);

Console.WriteLine(cpuUsage.NextValue() + " %");
Console.Read();
}

Note:
Observe that we are calling NextValues() twice and after a delay of 1 second. This is because performance counters need two samples to perform the calculation and the counter value is updated once per second, hence the 1 second delay between the two calls.

How to calculate the CPU Usage Programmatically using C#

Question is...
How to calculate the CPU Usage Programmatically using C#

The PerformanceCounter class represents a WindowsNT performance counter component. To read from a performance counter, we first create an instance of the PerformanceCounter class supplying the CategoryName, CounterName, and InstanceName as parameters to the constructor and then call the NextValue() method to take a performance counter reading.

Import the namespaces System.Diagnostics and System.Threading.


static PerformanceCounter cpuUsage;
public static void Main(string[] args)
{
cpuUsage =
new PerformanceCounter("Processor", "% Processor Time", "_Total");

Console.WriteLine(cpuUsage.NextValue() + " %");
Thread.Sleep(1000);

Console.WriteLine(cpuUsage.NextValue() + " %");
Console.Read();
}

Note:
Observe that we are calling NextValues() twice and after a delay of 1 second. This is because performance counters need two samples to perform the calculation and the counter value is updated once per second, hence the 1 second delay between the two calls.

How to calculate the CPU Usage Programmatically using C#

Question is...
How to calculate the CPU Usage Programmatically using C#

The PerformanceCounter class represents a WindowsNT performance counter component. To read from a performance counter, we first create an instance of the PerformanceCounter class supplying the CategoryName, CounterName, and InstanceName as parameters to the constructor and then call the NextValue() method to take a performance counter reading.

Import the namespaces System.Diagnostics and System.Threading.


static PerformanceCounter cpuUsage;
public static void Main(string[] args)
{
cpuUsage =
new PerformanceCounter("Processor", "% Processor Time", "_Total");

Console.WriteLine(cpuUsage.NextValue() + " %");
Thread.Sleep(1000);

Console.WriteLine(cpuUsage.NextValue() + " %");
Console.Read();
}

Note:
Observe that we are calling NextValues() twice and after a delay of 1 second. This is because performance counters need two samples to perform the calculation and the counter value is updated once per second, hence the 1 second delay between the two calls.

Count Words and Characters in a String using C#

Question is...
Count Words and Characters in a String using C#

A user recently asked me a question on how to use Regular Expressions to count words and characters in a string. Here’s how:

First add a reference to System.Text.RegularExpressions

Here the strOriginal is your string.

// Count words
MatchCollection wordColl =
Regex.Matches(strOriginal, @"[\S]+");

Console.WriteLine(wordColl.Count.ToString());

// Count characters. White space is treated as a character
MatchCollection charColl = Regex.Matches(strOriginal, @".");
Console.WriteLine(charColl.Count.ToString());

Count Words and Characters in a String using C#

Question is...
Count Words and Characters in a String using C#

A user recently asked me a question on how to use Regular Expressions to count words and characters in a string. Here’s how:

First add a reference to System.Text.RegularExpressions

Here the strOriginal is your string.

// Count words
MatchCollection wordColl =
Regex.Matches(strOriginal, @"[\S]+");

Console.WriteLine(wordColl.Count.ToString());

// Count characters. White space is treated as a character
MatchCollection charColl = Regex.Matches(strOriginal, @".");
Console.WriteLine(charColl.Count.ToString());

Count Words and Characters in a String using C#

Question is...
Count Words and Characters in a String using C#

A user recently asked me a question on how to use Regular Expressions to count words and characters in a string. Here’s how:

First add a reference to System.Text.RegularExpressions

Here the strOriginal is your string.

// Count words
MatchCollection wordColl =
Regex.Matches(strOriginal, @"[\S]+");

Console.WriteLine(wordColl.Count.ToString());

// Count characters. White space is treated as a character
MatchCollection charColl = Regex.Matches(strOriginal, @".");
Console.WriteLine(charColl.Count.ToString());

Find Information about your Network Cards using C#

Find Information about your Network Cards using C#

Here’s a small snippet of code of how to find out which network cards are enabled and able to transmit data on your machine. Here’s the code.

Add a reference to System.Net.NetworkInformation


var nics = NetworkInterface.GetAllNetworkInterfaces()
.Where(o => o.OperationalStatus == OperationalStatus.Up);

foreach (var item in nics)
{
Response.Write(item.Description + "<br />");
Response.Write(item.Name + "<br />");
Response.Write(item.Speed + "<br />");
Response.Write(item.NetworkInterfaceType + "<br /><br />");
}

Find Information about your Network Cards using C#

Find Information about your Network Cards using C#

Here’s a small snippet of code of how to find out which network cards are enabled and able to transmit data on your machine. Here’s the code.

Add a reference to System.Net.NetworkInformation


var nics = NetworkInterface.GetAllNetworkInterfaces()
.Where(o => o.OperationalStatus == OperationalStatus.Up);

foreach (var item in nics)
{
Response.Write(item.Description + "<br />");
Response.Write(item.Name + "<br />");
Response.Write(item.Speed + "<br />");
Response.Write(item.NetworkInterfaceType + "<br /><br />");
}

Find Information about your Network Cards using C#

Find Information about your Network Cards using C#

Here’s a small snippet of code of how to find out which network cards are enabled and able to transmit data on your machine. Here’s the code.

Add a reference to System.Net.NetworkInformation


var nics = NetworkInterface.GetAllNetworkInterfaces()
.Where(o => o.OperationalStatus == OperationalStatus.Up);

foreach (var item in nics)
{
Response.Write(item.Description + "<br />");
Response.Write(item.Name + "<br />");
Response.Write(item.Speed + "<br />");
Response.Write(item.NetworkInterfaceType + "<br /><br />");
}

Hiding a File using C#

Hiding a File using C#

The FileInfo class is very useful class that contains methods for the creation, copying, deletion, moving, and opening of files. Here’s how to hide a file using C#.


class Program
{
static void Main(string[] args)
{
try
{
string filePath = @"D:\Network.txt";
FileInfo f = new FileInfo(filePath);
f.Attributes = FileAttributes.Hidden;
Console.WriteLine("File Hidden");
}
catch (Exception ex)
{
// handle ex
}
}
}

Hiding a File using C#

Hiding a File using C#

The FileInfo class is very useful class that contains methods for the creation, copying, deletion, moving, and opening of files. Here’s how to hide a file using C#.


class Program
{
static void Main(string[] args)
{
try
{
string filePath = @"D:\Network.txt";
FileInfo f = new FileInfo(filePath);
f.Attributes = FileAttributes.Hidden;
Console.WriteLine("File Hidden");
}
catch (Exception ex)
{
// handle ex
}
}
}

Hiding a File using C#

Hiding a File using C#

The FileInfo class is very useful class that contains methods for the creation, copying, deletion, moving, and opening of files. Here’s how to hide a file using C#.


class Program
{
static void Main(string[] args)
{
try
{
string filePath = @"D:\Network.txt";
FileInfo f = new FileInfo(filePath);
f.Attributes = FileAttributes.Hidden;
Console.WriteLine("File Hidden");
}
catch (Exception ex)
{
// handle ex
}
}
}

Retrieve a List of the Services Running on your Computer using C#

Retrieve a List of the Services Running on your Computer using C#

The ServiceController class can be used to retrieve a list of the services running on your computer. The GetServices() can be used to do so. Here’s an example to list the services that are running on your machine

Add a reference to System.ServiceProcess.

Then write the following code:


using System;
using System.ServiceProcess;

namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
try
{
ServiceController[] sController =
ServiceController.GetServices();
foreach (ServiceController sc in sController)
{
if (sc.Status.ToString() == "Running")
{
Console.WriteLine(sc.ServiceName);
}
}
Console.ReadLine();
}
catch (Exception ex)
{
// handle ex
}
}
}
}

Retrieve a List of the Services Running on your Computer using C#

Retrieve a List of the Services Running on your Computer using C#

The ServiceController class can be used to retrieve a list of the services running on your computer. The GetServices() can be used to do so. Here’s an example to list the services that are running on your machine

Add a reference to System.ServiceProcess.

Then write the following code:


using System;
using System.ServiceProcess;

namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
try
{
ServiceController[] sController =
ServiceController.GetServices();
foreach (ServiceController sc in sController)
{
if (sc.Status.ToString() == "Running")
{
Console.WriteLine(sc.ServiceName);
}
}
Console.ReadLine();
}
catch (Exception ex)
{
// handle ex
}
}
}
}

Retrieve a List of the Services Running on your Computer using C#

Retrieve a List of the Services Running on your Computer using C#

The ServiceController class can be used to retrieve a list of the services running on your computer. The GetServices() can be used to do so. Here’s an example to list the services that are running on your machine

Add a reference to System.ServiceProcess.

Then write the following code:


using System;
using System.ServiceProcess;

namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
try
{
ServiceController[] sController =
ServiceController.GetServices();
foreach (ServiceController sc in sController)
{
if (sc.Status.ToString() == "Running")
{
Console.WriteLine(sc.ServiceName);
}
}
Console.ReadLine();
}
catch (Exception ex)
{
// handle ex
}
}
}
}

Optional parameters and named parameters in C# 4.0

Optional parameters and named parameters in C# 4.0

Imagine you have two List. Two new features to C# 4.0 are optional parameters and named parameters.

Optional parameters have been a part of VB.Net but it's now possible to do this in C#. Instead of using overload methods, you can do this in C#:

private string SomeMethod(string givenName,
string surname = "Kannan",
int age = 10)
{
return givenName + " " + surname;
}

The second and third parameters, surname & age, both have default values. The only parameter required is givenName. To call this method you can either write this:

string name = null;
name = SomeMethod("Arjun");

That will return Arjun Kannan. You can also do this:

string name = null;
name = SomeMethod("FName", "LName");

The value returned is FName LName. But what if you didn't want to specify a surname but you did want to pass the age? You can do this by using named parameters:

string name = null;
name = SomeMethod("Rangoli", age: 20);

These are nice additions to the language.

Optional parameters and named parameters in C# 4.0

Optional parameters and named parameters in C# 4.0

Imagine you have two List. Two new features to C# 4.0 are optional parameters and named parameters.

Optional parameters have been a part of VB.Net but it's now possible to do this in C#. Instead of using overload methods, you can do this in C#:

private string SomeMethod(string givenName,
string surname = "Kannan",
int age = 10)
{
return givenName + " " + surname;
}

The second and third parameters, surname & age, both have default values. The only parameter required is givenName. To call this method you can either write this:

string name = null;
name = SomeMethod("Arjun");

That will return Arjun Kannan. You can also do this:

string name = null;
name = SomeMethod("FName", "LName");

The value returned is FName LName. But what if you didn't want to specify a surname but you did want to pass the age? You can do this by using named parameters:

string name = null;
name = SomeMethod("Rangoli", age: 20);

These are nice additions to the language.

Optional parameters and named parameters in C# 4.0

Optional parameters and named parameters in C# 4.0

Imagine you have two List. Two new features to C# 4.0 are optional parameters and named parameters.

Optional parameters have been a part of VB.Net but it's now possible to do this in C#. Instead of using overload methods, you can do this in C#:

private string SomeMethod(string givenName,
string surname = "Kannan",
int age = 10)
{
return givenName + " " + surname;
}

The second and third parameters, surname & age, both have default values. The only parameter required is givenName. To call this method you can either write this:

string name = null;
name = SomeMethod("Arjun");

That will return Arjun Kannan. You can also do this:

string name = null;
name = SomeMethod("FName", "LName");

The value returned is FName LName. But what if you didn't want to specify a surname but you did want to pass the age? You can do this by using named parameters:

string name = null;
name = SomeMethod("Rangoli", age: 20);

These are nice additions to the language.

List the Drives on your Computer using C#

List the Drives on your Computer using C#?

Imagine you have two List. If you want to create a program to provide information about your Computer Drive, then use the System.IO.DriveInfo class.

The DriveInfo class can be used to determine the drives available on your computer, drive capacity, free space, type of drives etc. as shown below:


// Add namespace System.IO;

DriveInfo[] myDrives = DriveInfo.GetDrives();

foreach (DriveInfo di in myDrives)
{
Console.WriteLine(di.Name);
if (di.IsReady)
{
Console.WriteLine(di.TotalSize);
Console.WriteLine(di.DriveFormat);

Console.WriteLine(di.AvailableFreeSpace);
Console.WriteLine(di.TotalFreeSpace);

Console.WriteLine(di.DriveType);
Console.WriteLine(di.VolumeLabel);
}
}

List the Drives on your Computer using C#

List the Drives on your Computer using C#?

Imagine you have two List. If you want to create a program to provide information about your Computer Drive, then use the System.IO.DriveInfo class.

The DriveInfo class can be used to determine the drives available on your computer, drive capacity, free space, type of drives etc. as shown below:


// Add namespace System.IO;

DriveInfo[] myDrives = DriveInfo.GetDrives();

foreach (DriveInfo di in myDrives)
{
Console.WriteLine(di.Name);
if (di.IsReady)
{
Console.WriteLine(di.TotalSize);
Console.WriteLine(di.DriveFormat);

Console.WriteLine(di.AvailableFreeSpace);
Console.WriteLine(di.TotalFreeSpace);

Console.WriteLine(di.DriveType);
Console.WriteLine(di.VolumeLabel);
}
}

List the Drives on your Computer using C#

List the Drives on your Computer using C#?

Imagine you have two List. If you want to create a program to provide information about your Computer Drive, then use the System.IO.DriveInfo class.

The DriveInfo class can be used to determine the drives available on your computer, drive capacity, free space, type of drives etc. as shown below:


// Add namespace System.IO;

DriveInfo[] myDrives = DriveInfo.GetDrives();

foreach (DriveInfo di in myDrives)
{
Console.WriteLine(di.Name);
if (di.IsReady)
{
Console.WriteLine(di.TotalSize);
Console.WriteLine(di.DriveFormat);

Console.WriteLine(di.AvailableFreeSpace);
Console.WriteLine(di.TotalFreeSpace);

Console.WriteLine(di.DriveType);
Console.WriteLine(di.VolumeLabel);
}
}

Compare Two List of Strings in C#

Compare Two List of Strings in C#?

Imagine you have two List. You want to quickly compare them to see if all the elements match each other. Here's how to do so:

List<string> strList1 = new List<string>
{
"Jack", "And", "Jill", "Went", "Up", "The", "Hill"
};

List<string> strList2 = new List<string>
{
"Jack", "And", "Jill", "Went", "Down", "The", "Hill"
};

bool result = strList1.SequenceEqual(strList2);

Compare Two List of Strings in C#

Compare Two List of Strings in C#?

Imagine you have two List. You want to quickly compare them to see if all the elements match each other. Here's how to do so:

List<string> strList1 = new List<string>
{
"Jack", "And", "Jill", "Went", "Up", "The", "Hill"
};

List<string> strList2 = new List<string>
{
"Jack", "And", "Jill", "Went", "Down", "The", "Hill"
};

bool result = strList1.SequenceEqual(strList2);

Compare Two List of Strings in C#

Compare Two List of Strings in C#?

Imagine you have two List. You want to quickly compare them to see if all the elements match each other. Here's how to do so:

List<string> strList1 = new List<string>
{
"Jack", "And", "Jill", "Went", "Up", "The", "Hill"
};

List<string> strList2 = new List<string>
{
"Jack", "And", "Jill", "Went", "Down", "The", "Hill"
};

bool result = strList1.SequenceEqual(strList2);

How to check if a TCP port is blocked using C#

How to check if a TCP port is blocked using C#?

In order to check if a TCP port is blocked, use the System.Net and System.Net.Sockets classes as shown below:

protected void Button1_Click(object sender, EventArgs e)
{
string host = "localhost";
int port = 6900;
IPAddress addr = (IPAddress)Dns.GetHostAddresses(host)[0];
try
{
TcpListener tcpList = new TcpListener(addr, port);
tcpList.Start();
}
catch (SocketException sx)
{
// Catch exception here if port is blocked
}
}

How to check if a TCP port is blocked using C#

How to check if a TCP port is blocked using C#?

In order to check if a TCP port is blocked, use the System.Net and System.Net.Sockets classes as shown below:

protected void Button1_Click(object sender, EventArgs e)
{
string host = "localhost";
int port = 6900;
IPAddress addr = (IPAddress)Dns.GetHostAddresses(host)[0];
try
{
TcpListener tcpList = new TcpListener(addr, port);
tcpList.Start();
}
catch (SocketException sx)
{
// Catch exception here if port is blocked
}
}

How to check if a TCP port is blocked using C#

How to check if a TCP port is blocked using C#?

In order to check if a TCP port is blocked, use the System.Net and System.Net.Sockets classes as shown below:

protected void Button1_Click(object sender, EventArgs e)
{
string host = "localhost";
int port = 6900;
IPAddress addr = (IPAddress)Dns.GetHostAddresses(host)[0];
try
{
TcpListener tcpList = new TcpListener(addr, port);
tcpList.Start();
}
catch (SocketException sx)
{
// Catch exception here if port is blocked
}
}

Convert Domain Name to IP Address

How to convert Domain Name to IP Address in C#?

The answer is quiet simple. Just use the System.Net.Dns class

using System.Net;

protected void Page_Load(object sender, EventArgs e)
{
foreach (IPAddress address in Dns.GetHostAddresses("www.youraddress.com"))
{
Response.Write(address.ToString());
}
}

Convert Domain Name to IP Address

How to convert Domain Name to IP Address in C#?

The answer is quiet simple. Just use the System.Net.Dns class

using System.Net;

protected void Page_Load(object sender, EventArgs e)
{
foreach (IPAddress address in Dns.GetHostAddresses("www.youraddress.com"))
{
Response.Write(address.ToString());
}
}

Convert Domain Name to IP Address

How to convert Domain Name to IP Address in C#?

The answer is quiet simple. Just use the System.Net.Dns class

using System.Net;

protected void Page_Load(object sender, EventArgs e)
{
foreach (IPAddress address in Dns.GetHostAddresses("www.youraddress.com"))
{
Response.Write(address.ToString());
}
}

Multiple Inheritance in C#

C# supports single inheritance, however they do support multiple 'interface' inheritance:

Here's a sample demonstrating the same:


//Single Inheritance

public class A
{
public A() { }
}

public class B : A
{
public B() { }
}


//Multiple Interface Inheritance

interface IComparable
{
int CompareTo(object obj);
}

interface ISomethingElse
{
int EqualTo();
}


public class Z : IComparable, ISomethingElse
{
public int CompareTo(object obj)
{
// implementation code goes here
}


public int EqualTo()
{
// implementation code goes here
}
}

Multiple Inheritance in C#

C# supports single inheritance, however they do support multiple 'interface' inheritance:

Here's a sample demonstrating the same:


//Single Inheritance

public class A
{
public A() { }
}

public class B : A
{
public B() { }
}


//Multiple Interface Inheritance

interface IComparable
{
int CompareTo(object obj);
}

interface ISomethingElse
{
int EqualTo();
}


public class Z : IComparable, ISomethingElse
{
public int CompareTo(object obj)
{
// implementation code goes here
}


public int EqualTo()
{
// implementation code goes here
}
}

Multiple Inheritance in C#

C# supports single inheritance, however they do support multiple 'interface' inheritance:

Here's a sample demonstrating the same:


//Single Inheritance

public class A
{
public A() { }
}

public class B : A
{
public B() { }
}


//Multiple Interface Inheritance

interface IComparable
{
int CompareTo(object obj);
}

interface ISomethingElse
{
int EqualTo();
}


public class Z : IComparable, ISomethingElse
{
public int CompareTo(object obj)
{
// implementation code goes here
}


public int EqualTo()
{
// implementation code goes here
}
}