jeudi 29 octobre 2020

Setting a value type VARIABLE using reflection [closed]

I need to set the value of a value type VARIABLE (NOT a property, or field on a class) to a value using reflection.

Here's what I'd like to accomplish:

int myAge =0;
typeof(myAge).SetValue(myAge,33);
Assert.Equal(33, myAge);

is this possible?





Aucun commentaire:

Enregistrer un commentaire