我是 c# 的新手,我一直在玩弄它,并被困在从方法中返回有用的东西。任何帮助都会很棒。
我现在有这个:
在Form1.cs
:
Animal NewAnimal = new Animal("Jack", "Ramp");
在Animal.cs
:
public Animal(string Fname, string Lname)
{
if (Fname == "Jack" | Lname == "Ramp")
{
string FullName;
FullName = Fname + " " + Lname;
//return FullName; <--- This is what i tried but didn't work--->
}
}
//return FullName; <--- And Also tried this it didn't work --->
也许从我尝试过的那些我做错了什么?如何将 FullName 返回到 Form1.cs 并将其显示在标签中?