How much memory do an empty string and null
take?
I found this question, which tells about the String.Empty
memory allocation but not null
.
If I want to store an empty string or null
in session which one would take less space?
class MyClass
{
public string One { get; set; }
public string Two { get; set; }
public MyClass(string one,string two)
{
One = one;
Two = two;
}
}
class Main
{
var emp = new MyClass(String.Empty, String.Empty);
var nul = new MyClass(null,null);
}
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…