Click here to Skip to main content
15,903,012 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Example

Which type of Values can be  initialize  and Declare to the  different instance variables in C#


If int i=10;

double f=20.0f;

like wise

person p = ?
order o = ?

Here Person, Order are class

IEnumerable i =?

IInterface J=?

Enum k =?

Please kindly provide answers to my questions..I have confusion.

Thank you

What I have tried:

Which type of Values can be  initialize  and Declare to the  different instance variables in C#
Posted
Updated 20-Dec-17 9:49am

1 solution

All values can be initialised, whether basic types like int and float, or class types like person or order. Value (i.e. basic) types can be initialised with the appropriate values, but class objects need to be initialised by the class constructor, something like:
C#
int i = 10;
float f = 3.14;

person me = new person();
order food = new order();

This should all be explained in your course notes, or see C# Programming Guide | Microsoft Docs[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900