开发者

Get the value of entered by the user in the class property

开发者 https://www.devze.com 2023-02-22 04:07 出处:网络
I have the class defined as below public partial class School { public StudentDetails StudentDetails; private List<string> studentcount;

I have the class defined as below

public partial class School
{
 public StudentDetails StudentDetails;
 private List<string> studentcount;
    public List<string> StudentCount
    {
        get { return studentcount; }
        set { studentcount= value; }
    }
}
public enum StudentDetails
{
    Male,
    Female,
}

In my code, I have

   if (ctl.Contains("StudentDetails "))
   {
    ctrlStr = ctl.ToString();
    School.StudentDetails = (Request.Form[ctrlStr]);
   }

error above is cannot convert string to School.StudentDetails

 if(ctl.Contains("StudentCount"))
    {
     School.Student开发者_开发技巧Count=(Request.Form[ctrlStr]);
    }


   error here is cannot convert string to List<string>

Can you help me with the syntax


Try

School.StudentDetails =  Enum.Parse(typeof(StudentDetails), Request.Form[ctrlStr])

for the first error.

Regarding the second one, why is student count a list of string?

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号