I would like a class that is not static to be available to the entire application. At first I thought of making this class static, but for obscure reasons that is not the case, I can not make it static.
Then I researched something and found some things, following example:
Considering the classes
public class TesteInstancia
{
public decimal A { get; set; }
public string B { get; set; }
}
public static class TesteStatic
{
public static TesteInstancia testeInstancia;
}
So I understand the class TesteStatic
will get the reference to the object TesteInstancia
.
How to pass the value instead of the reference?
Is there a way to do this in a "better" way?
EDIT
Thanks to everyone for the clarification, I came up with a "solution". Creating a clone of the original class can be changed that would not reflect on the clone, this solves my problem for now, I'll post here.
public class TesteInstancia : ICloneable
{
public decimal A { get; set; }
public string B { get; set; }
public object Clone()
{
return this.MemberwiseClone();
}
}
public static class TesteStatic
{
public static TesteInstancia MyProperty { get; set; }
}