Skip to content

Commit

Permalink
.net-added-interface-example
Browse files Browse the repository at this point in the history
  • Loading branch information
rajjitlai committed Oct 11, 2024
1 parent 1826c32 commit 6c16b29
Show file tree
Hide file tree
Showing 12 changed files with 139 additions and 0 deletions.
1 change: 1 addition & 0 deletions dotNET/practical/practical-01/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

11 changes: 11 additions & 0 deletions dotNET/practical/practical-01/practical-01.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<RootNamespace>practical_01</RootNamespace>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

</Project>
25 changes: 25 additions & 0 deletions dotNET/practical/practical-01/practical-01.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.12.35323.107
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "practical-01", "practical-01.csproj", "{7453CE89-9890-4239-978B-5D015A258709}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{7453CE89-9890-4239-978B-5D015A258709}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{7453CE89-9890-4239-978B-5D015A258709}.Debug|Any CPU.Build.0 = Debug|Any CPU
{7453CE89-9890-4239-978B-5D015A258709}.Release|Any CPU.ActiveCfg = Release|Any CPU
{7453CE89-9890-4239-978B-5D015A258709}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {081D5BAF-0BAE-4EAC-A7CE-FCD1A65F8F10}
EndGlobalSection
EndGlobal
67 changes: 67 additions & 0 deletions dotNET/theory/interface/interfaceEg/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
// from A to B and C

interface iUser
{
void getDetails(string x);
}

class User : iUser
{
public void getDetails(string name)
{
Console.WriteLine("My name is {0}", name);
}
}

class User2 : iUser
{
public void getDetails(string address)
{
Console.WriteLine("My address is {0}", address);
}
}

class Program
{
static void Main()
{
iUser u = new User();
u.getDetails("John Doe");

iUser u2 = new User2();
u2.getDetails("123 Main St");
}
}

// from A and B to C
interface iUser
{
void getName(string x);
}

interface iAddress
{
void getAddress(string a);
}

class User : iUser, iAddress
{
public void getName(string name)
{
Console.WriteLine("My name is {0}", name);
}
public void getAddress(string address)
{
Console.WriteLine("My address is {0}", address);
}
}

class Program
{
static void Main()
{
User u = new User();
u.getName("John Doe");
u.getAddress("123 Main St");
}
}
10 changes: 10 additions & 0 deletions dotNET/theory/interface/interfaceEg/interfaceEg.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

</Project>
25 changes: 25 additions & 0 deletions dotNET/theory/interface/interfaceEg/interfaceEg.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.12.35323.107
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "interfaceEg", "interfaceEg.csproj", "{DACE2A75-8794-4CFE-9D51-EDFB6EDF83E6}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{DACE2A75-8794-4CFE-9D51-EDFB6EDF83E6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{DACE2A75-8794-4CFE-9D51-EDFB6EDF83E6}.Debug|Any CPU.Build.0 = Debug|Any CPU
{DACE2A75-8794-4CFE-9D51-EDFB6EDF83E6}.Release|Any CPU.ActiveCfg = Release|Any CPU
{DACE2A75-8794-4CFE-9D51-EDFB6EDF83E6}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {D4A1F73A-68EB-4F0C-9BCF-B0C83FE6D132}
EndGlobalSection
EndGlobal
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit 6c16b29

Please sign in to comment.