مكتبه لاكواد سي شارب
مكتبه لاكواد سي شارب
System.Net.IPHostEntry ass = System.Net.Dns.GetHostByName("[www.almohandes.org](http://www.almohandes.org)");
System.Net.IPAddress []ip = ass.AddressList;
MessageBox.Show(ip[0].ToString());
انشاء مجلد
System.IO.Directory.CreateDirectory ("c:\almohandes");
حذف مجلد
System.IO.Directory.Delete("c:\almohandes");
نقل مجلد
System.IO.Directory.Move ("c:\almohandes", "c:\almohandes");
pictureBox1.Image = System.Drawing.Image.FromFile(System.Environment.CurrentDirectory + @"csharp.jpg");
تستطيع تنفيذ الكود بشرط ان يوجد عندك صوره في نفس مسار البرنامج
ويكون اسم الصوره csharp.jpg
طبعا تستطيع التعديل في الكود وتحديد مسار مختلف وصورة مختلفة
MessageBox.Show(System.Environment.UserName);
System.Diagnostics.Process s = new System.Diagnostics.Process();
s.StartInfo.FileName ="C:\\Program Files\\MacromediaFlash 5\\Flash.exe";
s.Start();
MessageBox.Show (System.Environment.CurrentDirectory );
جميع الأعضاء الموجودة في هذه الفئة هي أعضاء ساكنة Static
using System;
using System.Runtime.InteropServices;
using System.Windows.Forms;
using System.Text;
public class InternetConnectionState
{
[DllImport("wininet.dll", CharSet = CharSet.Auto)]
private static extern int InternetGetConnectedStateEx(
ref int lpdwFlags,
[MarshalAs(UnmanagedType.LPTStr)]
StringBuilder lpszConnectionName,
int dwNameLen,
int dwReserved);
static StringBuilder connectionName = new StringBuilder(255);// Buffer initializing
public static bool IsConnected()
{
int retVal = 0;
retVal = InternetGetConnectedStateEx(ref retVal, connectionName, connectionName.Capacity, 0);
if(retVal == 1)
return true;
else
return false;
}
public static string ConnectionName
{
get
{
return connectionName.ToString();
}
}
}
كود لطبع التاريخ والوقت
using System;
class myApp
{
public static void Main()
{
DateTime CurrTime = DateTime.Now;
Console.WriteLine ( "d: {0:d}" , CurrTime );
Console.WriteLine ( "D: {0:D}" , CurrTime );
Console.WriteLine ( "f: {0:f}" , CurrTime );
Console.WriteLine ( "F: {0:F}" , CurrTime );
Console.WriteLine ( "g: {0:g}" , CurrTime );
Console.WriteLine ( "G: {0:G}" , CurrTime );
Console.WriteLine ( "m: {0:m}" , CurrTime );
Console.WriteLine ( "M: {0:M}" , CurrTime );
Console.WriteLine ( "r: {0:r}" , CurrTime );
Console.WriteLine ( "R: {0:R}" , CurrTime );
Console.WriteLine ( "s: {0:s}" , CurrTime );
//Console.WriteLine ("S: {0:S}" , CurrTime ); // error!!!
Console.WriteLine ( "t: {0:t}" , CurrTime );
Console.WriteLine ( "T: {0:T}" , CurrTime );
Console.WriteLine ( "u: {0:u}" , CurrTime );
Console.WriteLine ( "U: {0:U}" , CurrTime );
Console.WriteLine ( "y: {0:y}" , CurrTime );
Console.WriteLine ( "Y: {0:Y}" , CurrTime );
}
}
[CENTER]داله الصوت
اولا نضيف هذا الأمر اعلى الشاشة البرمجية(فوق الكلاس)
using System.Runtime.InteropServices;
ثم نعرف دالة كالأتي
[DllImport("winmm.dll")]
private static extern int PlaySoundA(string a,int b , int c);
ثم نستدعي الدالة في زر أمر كالتالي
PlaySoundA(@"file name here",0,0);
[/center]
مثال على التأكد من تاريخ معين باستخدام الحد الأقصى للتاريخ في تقويم
calendar
if(System.DateTime.Now.Date.CompareTo(calendar.MaxDate)>=0)
{
if(MessageBox.Show(this.ProductName+" version "+this.ProductVersion+" is expired and must be updated!nDo you want to check for updates now?",this.ProductName+" :: Version Expired",MessageBoxButtons.YesNo)==System.Windows.Forms.DialogResult.Yes)
System.Diagnostics.Process.Start("http://myWebsite/myProduct.html");
Application.Exit();
}
Here you can load a text file into a rich text box
richTextBox1.LoadFile(@"icitc.icit",RichTextBoxStreamType.PlainText);
To close the application after clicking an object called "exit
private void exit_Click(object sender, System.EventArgs e)
{
if(MessageBox.Show("Are you sure you want to exit ICit Calendar?",this.ProductName+" :: Exit",MessageBoxButtons.YesNo)==System.Windows.Forms.DialogResult.Yes)
Application.Exit();
}
لمعرفة تاريخ اليوم ووضعه في كائن :
private void today_Select(object sender, System.EventArgs e)
{
myDate.Text=System.DateTime.Now.Date.ToLongDateString();
}
إظهار رسالة:
MessageBox.Show("my text","label");
1. Write a function that takes length and breadth of a rectangle as argument and returns area. Check this function in main class.
2. Write a program to demonstrate Operator overloading (for --, = operator) for class TwoD point.
3. Write a program to demonstrate the Runtime polymorphism with Virtual functions.(Hint: Take virtual function for calculation of area of triangle and rectangle)
4. Write a class having an abstract method area. Override this method in two derived classes for calculation of area of rectangle and triangle.
5. Write a program which inherits a base class and two interfaces. Show this by a function.
هاذي برامج ماعرفت احلها تكفووون يالنشااما
موضوع يستحق الاعجاب شكرا جزيلا