I'm trying to make a global interface that will receive different type of class. how do I convert.
how do I pass and get an object and convert it to specific class
public void Generate()
{
Student s = new Student
{
Id = Entry; // binded entry
};
var student = method("Student",s)
if(student != null)
{
//binded labels
Name = Student.Name;
Gender = Student.Gender;
Age = Student.Age;
Course = Student.Course;
}
}
public async Task<object> method(string condition,object obj)
{
switch(condition)
{
case "Student":
var student = get from database where id= obj.id;
return student;
case "Teacher":
var teacher = get from database where id= obj.id;
return Teacher;
}
}
The question is how do I convert the passed object into a specific type of class to use it for querying into database. Same as returned value