Hi i have 2 class (YarnBLL, DyingBLL) with same property.
i need to create a instace based on switch case
- public String insave(String name)
- {
- var obj;
- switch (name)
- {
- case "YARN":
- obj = new YarnBLL();
- break;
- case "WEAVING":
- obj = new DyingBLL();
- break;
- default:
- break;
- }
- obj.InDate = Utils.ConvertStringToDate(txtDate.Text);
- obj.CategoryName = ddlCategory.SelectedItem.ToString();
- obj.Save();
- }
var obj;
it shows
Error 1 Implicitly-typed local variables must be initialized

Mario ScheerenRank #1,371 · 1.2K reputationPosted Jul 6, 2019, 4:49 AM EDT
Jaish MathewsRank #225 · 11K reputationPosted Jul 6, 2019, 8:14 AM EDT
Mageshwaran RRank #411 · 6.1K reputationPosted Nov 23, 2019, 7:39 AM EST