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");
}

this is source code to create .... system information tray icon
you can download this from here

C # sharp: login dialogbox



 source code to create a login box
you can download source from here

c sharp in detail

free book for c# lang
you can download this from here
boook create by mr: jon jagger

C # sharp : Arrays


Arrays, Collections & String Manipulation
Lesson Plan
Today we will explore arrays, collections and string manipulation in C#. First of all, we will explore
multidimensional rectangular and jagged arrays. We will also explore how foreach iterates through a collection.
Then we will move to collections and see how they are implemented in C#. Later, we will explore different
collections like ArrayLists, Stacks, Queues and Dictionaries. Finally, we will see how strings are manipulated in
C#. We will explore both the string and the StringBuilder types.
Arrays Revisited
As we have seen earlier, an array is a sequential collection of elements of a similar data type. In C#, an array is an
object and thus a reference type, and therefore they are stored on the heap. We have only covered single dimension
arrays in the previous lessons, now we will explore multidimensional arrays.
Multidimensional Arrays
A multidimensional array is an 'array of arrays'. A multidimensional array is the one in which each element of the
array is an array itself. It is similar to tables in a database where each primary element (row) is a collection of
secondary elements (columns). If the secondary elements do not contain a collection of other elements, it is called
a 2-dimensional array (the most common type of multidimensional array), otherwise it is called an n-dimensional
array where n is the depth of the chain of arrays. There are two types of multidimensional arrays in C#:
•  Rectangular array (one in which each row contains an equal number of columns)
•  Jagged array (one in which each row does not necessarily contain an equal number of columns)
The images below show what the different kinds of arrays look like. The figure also shows the indexes of different
elements of the arrays. Remember, the first element of an array is always zero (0).



REFERENCES:C# School book - 
programmersheaven




Java script - Various times of the world

Times of different places in the world


with my best : Mohamed basha

Java script - Google search on web



If you want to have google website on you site , a very powerful search engine you can put it in your website


Here is the code in this textbox

                           with my best     :      Mohamed Basha

Shut down, restart, log off and forced log off system using c sharp

In this article, I am going to show, 
  1. How to Shut Down a machine 
  2. How to Log Off a machine
  3. How to forced log off a machine
  4. How to restart a machine using c# 
To perform our task, very first let us create a windows application project.   On form drag and drop four buttons for four different operations.  After design form will look like below 

1.gif 

Navigate to code behind of form and add reference of System.Runtime.InteropServices

Add a static extern method to Form.cs

[DllImport("user32.dll")]
public static extern int ExitWindowsEx(int operationFlag, int operationReason);

Log off  the System 

On click event of Log Off button, call ExitWindowsEX method with proper flag.  For log off  operation flag value is 0. 

private void btnLogOff_Click(object sender, EventArgs e)
{
    ExitWindowsEx(0, 0);
}

Forced Log off the System 

On click event of Forced Log Off button, call ExitWindowsEX method with proper flag.  For Forced  log off  operation flag value is 4. 

private void btnForcedLogOff_Click(object sender, EventArgs e)
{
   ExitWindowsEx(4, 0);
}

Shut Down the System

On click event of Shut down button, call ExitWindowsEX method with proper flag.  For shut down  operation flag value is 1. 

private void btnShutDown_Click(object sender, EventArgs e)
{
    ExitWindowsEx(1, 0);
}

Restart the System 

On click event of Restart button, call ExitWindowsEX method with proper flag.  For Restart  operation flag value is 2. 

private void btnRestart_Click(object sender, EventArgs e)
{
    ExitWindowsEx(2, 0);
}

Now when you run the application all system operation should be performed. 

For your reference full source code is given here 

Form.cs

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;

namespace SystmShutDownApp
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
        private void Form1_Load(object sender, EventArgs e)
        {
        }
        [DllImport("user32.dll")]
        public static extern int ExitWindowsEx(int operationFlag, int operationReason);
        private void btnRestart_Click(object sender, EventArgs e)
        {
              ExitWindowsEx(2, 0);
        }
        private void btnLogOff_Click(object sender, EventArgs e)
        {
            ExitWindowsEx(0, 0);
        }
        private void btnForcedLogOff_Click(object sender, EventArgs e)
        {
           ExitWindowsEx(4, 0);
        }
        private void btnShutDown_Click(object sender, EventArgs e)
        {
            ExitWindowsEx(1, 0);
        }
    }
}

Thanks for reading. I hope post was useful. Happy Coding. 

Link With in

Related Posts Plugin for WordPress, Blogger...