|
// Strukturalar kichik hajmdagi ma'lumotlarni to'plash uchun qulay
|
səhifə | 87/96 | tarix | 27.07.2023 | ölçüsü | 233,68 Kb. | | #137688 |
| 1-Mavzu 1-Mavzu Reja Klass a’zolariga ruxsatni boshqarish-fayllar.org
// Strukturalar kichik hajmdagi ma'lumotlarni to'plash uchun qulay.
using System;
// Определить структуру пакета,
struct PacketHeader {
public uint PackNum; // номер пакета
public ushort PackLen; // длина пакета
}
//PacketHeader strukturasidan foydalanish.
class Transaction {
static uint transacNum = 0;
PacketHeader ph; // Transaction sinfiga PacketHeader tuzilishini kiritish.
string accountNum;
double amount;
public Transaction(string ace, double val) {
// paket sarlavhasini yaratish
ph.PackNum = transacNum++;
ph.PackLen =512; // ishchi uzunlik
accountNum = ace;
amount = val;
}
// Bitim taqlid qilish.
public void sendTransaction() {
Console.WriteLine("Пакет #: " + ph.PackNum +
", Длина: " + ph.PackLen +
",\n Счет #: " + accountNum +
", Сумма: {0:C}\n", amount);
}
}
// Bitim paketi struktura tuzilishi foydalanish.
class PacketDemo {
static void Main() {
Transaction t = new Transaction("31243", -100.12);
Transaction t2 = new Transaction("AB4655", 345.25);
Transaction t3 = new Transaction("8475-09", 9800.00);
t.sendTransaction ();
t2.sendTransaction ();
t3.sendTransaction ();
}
}
Dostları ilə paylaş: |
|
|