How to Convert a string into Title Case in .Net C#


LabelName.Text = System.Threading.Thread.CurrentThread.CurrentCulture.TextInfo.ToTitleCase((“amit KUMAR”).ToLower());


Amit Kumar


How to add leading zeros to a number

I saw the question “How to add leading zeros to a number” on the ASP.NET forums countless times before. And often the answers provide solutions that work, but are overkill as well.

The two cleanest methods I know are String.Format and PadLeft.

   1:  Console.WriteLine("Using .ToString()");
   2:  Console.WriteLine(String.Format("{0:0000}", 16));
   4:  Console.WriteLine("-------------------");
   6:  Console.WriteLine("Using .PadLeft()");
   7:  Console.WriteLine(Convert.ToString(16).PadLeft(4, '0'));

You can see the result here.

//Using .ToString()
//Using .PadLeft()

How to add google map to your website.


To add the Google map on your web page. Simply paste the code given below.

<script src=”;v=2&amp;key=AIzaSyBVaXuUwG51lC0vu6q-E-PzaCGI_u6UX1A&sensor=false&#8221;
<script type=”text/javascript”>

function initialize() {
if (GBrowserIsCompatible()) {
var map = new GMap2(document.getElementById(“map_canvas”));
map.setCenter(new GLatLng(51.659369, -0.029843), 15);
marker = new GMarker(new GLatLng(51.659369, -0.029843));



Insert a div named “map_canvas” where you want to put map on your page.

<div id=”map_canvas” style=”width: 300px; height: 350px”></div>

For showing any address just pass the longitude and latitude values for your address and replace:
map.setCenter(new GLatLng(51.659369, -0.029843), 15);

Get longitute and latitute from address for google map

Note: you also need to change the Key for your project. You can generate new key from:

Get Google Map API Key for website

Get File Name From a Path

Hi All,
while working on File System, Sometime we need to extract the file name from a given path. In dot Net it is very simple task as Framework library provide a specific class for doing these kind of task. “Path” is the class under the System.IO namespace has various methods for working on path.
GetFileName is the method of this class that extract the File name from the path.

[Visual Basic]
Dim fileName As String = “C:\mydir\myfile.ext”
Dim pathname As String = “C:\mydir\”
Dim result As String
result = Path.GetFileName(fileName)
Console.WriteLine(“GetFileName(‘{0}’) returns ‘{1}'”, fileName, result)
result = Path.GetFileName(pathname)
Console.WriteLine(“GetFileName(‘{0}’) returns ‘{1}'”, pathname, result)

string fileName = @”C:\mydir\myfile.ext”;
string path = @”C:\mydir\”;
string result;
result = Path.GetFileName(fileName);
Console.WriteLine(“GetFileName(‘{0}’) returns ‘{1}'”,
fileName, result);
result = Path.GetFileName(path);
Console.WriteLine(“GetFileName(‘{0}’) returns ‘{1}'”,
path, result);