एक चर का आकार प्राप्त करने के लिए, sizeof का उपयोग किया जाता है।
int x; x = sizeof(int);
एक चर का आकार प्राप्त करने के लिए, आकार का उपयोग किए बिना, निम्न कोड आज़माएं -
// without using sizeof byte[] dataBytes = BitConverter.GetBytes(x); int d = dataBytes.Length;
यहाँ पूरा कोड है।
उदाहरण
using System;
class Demo {
public static void Main() {
int x;
// using sizeof
x = sizeof(int);
Console.WriteLine(x);
// without using sizeof
byte[] dataBytes = BitConverter.GetBytes(x);
int d = dataBytes.Length;
Console.WriteLine(d);
}
} आउटपुट
4 4