Value type and reference type objects in C#.Net

Опубликовано: 23 Февраль 2016
на канале: techsapphire
4,428
25

Value type and reference type seems to very small topic but it effect programming a lot. Value type are those whenever these are passed to any function then any change in value in calling function will never reflect into original source. Reference type are those whenever these are passed to any function then any change in value in calling function will reflect changes in original source. For value type datatypes you can implement reference call using ref and out keyword.
Class objects are by default reference type so making copy of them is also doing using new object and assigning value to each property individually. For passing object reference ref or out keyword is not required as class objects are by default reference type.
Difference between ref and out is:
ref keyword can be used in un-managed code as it don't give guarantee of any change or assignment of value to reference object passed. But out keyword in other place guarantee assignment or change to passed reference objects.
Note: you can not declare 2 methods with same name and having same type of parameters just making difference in key word used.


Смотрите видео Value type and reference type objects in C#.Net онлайн без регистрации, длительностью часов минут секунд в хорошем качестве. Это видео добавил пользователь techsapphire 23 Февраль 2016, не забудьте поделиться им ссылкой с друзьями и знакомыми, на нашем сайте его посмотрели 4,428 раз и оно понравилось 25 людям.