I have a doubt.
1. namespace JIMS.ViewModel.Stock
2. {
3. internal class StockGroupViewModel : JIMS.ViewModel.BaseViewModel
4. {
5. JIMSEntities dbContext = new JIMSEntities();
6.
7. public StockGroupViewModel()
8. {
9. dbContext = new JIMSEntities();
10. }
11. }
12. }
I have this class. And i want to know which is called first.
when i create an instance of this class
StockGroupViewModel s = new StockGroupViewModel();
Line 5 or Line 9.
Line 5 – it’s a field initializer which is executed before any code within the constructor.
From the spec: