5. Open an EXE on Button Click
Using System. Diagnostics
string str = @"C:\windows\system32 \notepad.exe”;
Process process = new Process();
process.StartInfo.FileName = str;
process.Start();
6. Only Number is Input in TextBox
private void textBox1_KeyPress(object sender, KeyPressEventArgs e)
{if (Char.IsDigit(e.KeyChar) )
{ MessageBox.Show("Bad Input");e.Handled = true; ;}}
Saturday, July 11, 2009
1. Convert String In Title Case C#
string s = "This is a test";
s = System.Globalization.CultureInfo.CurrentCulture.TextInfo.ToTitleCase(s.ToLower())
2. Add Enum in ArrayList
ShiftTime ss=new ShiftTime (); Note : ShiftTime is EnumList
string[] allKeys = System.Enum.GetNames(ss.GetType());
System.Collections.ArrayList al = new System.Collections.ArrayList();
al.AddRange(allKeys);
3. Configure CLR Trigger
sp_configure 'clr enabled', 1;
RECONFIGURE;
4. Convert ArrayList To String
ArrayList ar =new arrayList();
string jj=string .Empty;
jj=string.Join(“,”, (string []) ar.ToArray(typeof(string)))
DeleteDuplicateRecord From ArrayList
ar is ArrayList
int index;
for(int i=0; i<(ar.Count-1); i++)
{
index=ar.IndexOf(ar[i], i+1);
while( index>i )
{
ar.RemoveAt(index);
if( i<(ar.Count-1) )
{
index=ar.IndexOf(ar[i], i+1);
}
else
{
index=-1;
} } }
int index;
for(int i=0; i<(ar.Count-1); i++)
{
index=ar.IndexOf(ar[i], i+1);
while( index>i )
{
ar.RemoveAt(index);
if( i<(ar.Count-1) )
{
index=ar.IndexOf(ar[i], i+1);
}
else
{
index=-1;
} } }
Subscribe to:
Comments (Atom)