salam
shayad baratun taajob bar angiz bashe ke chera in codhaye sade va ebtedayee ro ferestam ama bayad khedmatetun begam ke doroste afrade motebaheri mesle shoma shayad be in kodha niazi nadashte bashan ama behtar didam ke in koda az samte ebtedayee ta pishrafte gozashte beshan kheli bishtar va behtar be nafe bacheha va karbara bashe
ba sepas
کد:
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;
namespace Add
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
int c;
c = add(Convert.ToInt32(textBox1.Text), Convert.ToInt32(textBox2.Text));
MessageBox.Show(c.ToString());
}
public int add(int a, int b)
{
return (a +b);
}
}
}
کلاس نویسی دو عدد:
کد:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Add_Class
{
class ClassAdd
{
public int a;
public int b;
public int c;
public ClassAdd(int A, int B)
{
a = A;
b = B;
}
public int classadd()
{
return (a + b);
}
}
}
فراخونی:
کد:
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;
namespace Add_Class
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
ClassAdd CA = new ClassAdd(Convert.ToInt32(textBox1.Text), Convert.ToInt32(textBox2.Text));
label1.Text= CA.classadd().ToString();
}
}
}
علاقه مندی ها (Bookmarks)