I have c# class i have different properties.
public class Employee
{
public int ID;
public string Name;
public int Age;
}
WebServices pp=new WebServices();
Employee emp= pp.GetEmpInfo();
//pp is an instance of webservices which is web referenced in the app.
emp.ID=100;
emp.Age=25;
I don’t assign/get return value for name from GetEmpInfo(), will that throw any exception?
If you have a class with 10 properties and don’t assign few, will it break the application?
Please share your thoughts. There is some code in production, i am not sure of the result, so am checking.
It will not break the application, the attributes will have their default value – objects and strings will be set to
null, booleans tofalse, integers/floats/doubles to0, chars to'\0'etc.You only might encounter null reference exceptions if you access object attributes that have not been set without checking them for null.