This program has three files. O/P expected is {1, E1, 10000} but no o/p at all. Please identify the error.
using System;
namespace PartialClassesAndMethodsDemoApp
{
partial class Employee
{
public override string ToString()
{
return "{" + EmployeeID + "," + Name + "," + Salary + "}";
}
}
}
--------------------------------------
using System;
namespace PartialClassesAndMethodsDemoApp
{
partial class Employee
{
public int EmployeeID;
public string Name;
public decimal Salary;
}
}
------------------------------------------
using System;
namespace PartialClassesAndMethodsDemoApp
{
class Program
{
static void Main(string[] args)
{
Employee emp = new Employee() { EmployeeID = 1, Name = "E1", Salary = 10000 };
}
}
}
Loading
VulpesPosted Jun 22, 2014, 1:15 PM
Posted Jun 24, 2014, 9:17 AM
VulpesPosted Jun 24, 2014, 8:24 AM
This can be found under Tools -> Options -> Environment -> Documents and I think is turned on by default.
So, the presenter of that video is probably either using that feature or the file wasn't really read-only in the first place.
But the point is that each division of a partial class must be marked with the 'partial' keyword. So, if you're intending to create one, it's best to mark it as partial when you save the first file so you don't have to change it later.
Posted Jun 24, 2014, 7:24 AM
Partial class is explained in the above website.
Author is saying if Employee class is read only file, we can create a partial class. But in same file he does modification (before Employee class he put a keyword "partial"). How can a read only class be modified? Problem is highlighted in the 2nd file.
Posted Jun 22, 2014, 3:09 PM