Projektdateien hinzufügen.
This commit is contained in:
10
BeispielThis/BeispielThis.csproj
Normal file
10
BeispielThis/BeispielThis.csproj
Normal file
@@ -0,0 +1,10 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
||||
36
BeispielThis/Program.cs
Normal file
36
BeispielThis/Program.cs
Normal file
@@ -0,0 +1,36 @@
|
||||
namespace BeispielThis
|
||||
{
|
||||
internal class Program
|
||||
{
|
||||
static void Main(string[] args)
|
||||
{
|
||||
Person batman = new Person("Batman");
|
||||
Person robin = new Person("Robin");
|
||||
Console.WriteLine(batman.GetName());
|
||||
Console.WriteLine(robin.GetName());
|
||||
batman.SetPartner(robin);
|
||||
//robin.SetPartner(batman);
|
||||
Console.WriteLine($"Batmans Partner: {batman.GetPartner().GetName()}");
|
||||
Console.WriteLine($"Robins Partner: {robin.GetPartner().GetName()}");
|
||||
}
|
||||
}
|
||||
class Person
|
||||
{
|
||||
private string name;
|
||||
private Person partner;
|
||||
public Person(string name)
|
||||
{
|
||||
this.name = name;
|
||||
}
|
||||
public string GetName() { return name; }
|
||||
public Person GetPartner() { return partner;}
|
||||
public void SetPartner(Person partner)
|
||||
{
|
||||
if (this.partner == null)
|
||||
{
|
||||
this.partner = partner;
|
||||
this.partner.SetPartner(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user