Pages

c # Format a String as Currency


When building a string for output to a web page, it’s useful to format any currency value in a human-friendly money format. This is extremely easy in C#.
The system format string works like this: {0:C}
For example, the following code example:

decimal moneyvalue = 1921.39m;
string html = String.Format("Order Total: {0:C}", moneyvalue);
Console.WriteLine(html);
Outputs the following:
Order Total: $1,921.39

It’s worth noting that you must pass in a numeric value to the String.Format statement. If you pass in a string value, it won’t format correctly. If your currency value is in a string, you need to convert it into a double first.

Get IP Address from DNS Hostname in C#



 
A frequent task when designing applications that work with TCP/IP and the internet is to lookup an IP address from a hostname. It’s much easier for users to deal with the hostname than having to type in an IP address.

First you’ll add the System.Net namespace to your using section:

using System.Net;

Example of code to get address from hostname:

string code2all = "www.google.com";
IPAddress[] addresslist = Dns.GetHostAddresses(code2all);
foreach (IPAddress theaddress in addresslist)
{
Console.WriteLine(theaddress.ToString());
Console.Read();
}

you can change site google.com to any site you want

java script : back ground Fade


 
 this code to make some effect to your blog or site       it's so very nice
try it now



Share/Bookmark

Java script - Scroll Background

Scroll Background
this code make scroll image background to your web site

don't forget change url of image url(resnf.JPG)  ................. Mohamed basha

c # How to write an Office Plug-In/Add-In Using C#.NET

There are many Win/Web applications where we would use Office...this
article throws light on how to add office plug-in/add-in using C#.NET
into your application.
Pls find more information about article here...


With Best Regards,
mohamed basha

c # ESC key

ESC key


Do this
create a button on the same form where you have to get hold of ESC key!
in the form properties check out CancelButton and set its value to the the button designed right now. now write the routine for that button if it is clicked.
you can also assign it at runtime like this:
(C#) this.CancelButton=button24;
(VB.NET) Me.CancelButton=button24
With Best Regards,
mohamed basha

c # function to test HHMM

function to test HHMM -- HoursMins using regular expression (REGEX)
private string TestHHMM()
{
string InputString = DateTime.Now.ToString("HHmm"); // "2200";
if (InputString.Length >= 2)
InputString = InputString.PadLeft(4, '0');
Regex RegexObj = new Regex("^([0-1]\\d
2[0-3])([0-5][0-9])$");
if (RegexObj.IsMatch(InputString))
Console.WriteLine("true");
else
Console.WriteLine("false");
return RegexObj.Replace(InputString, "$1:$2");
}

Link With in

Related Posts Plugin for WordPress, Blogger...