Search
 
SCRIPT & CODE EXAMPLE
 

CSHARP

return an interface or a class C#

// The return of interface as an instance of that interface
// Ff the instance has a few instances then no need to worry about the type of instance
// This example returns an object that has implemented Ic
public interface Ic
{
    int Type { get; }
    string Name { get; }
}

public class A : Ic
{
}

public class B : Ic
{
}

public Ic func(bool flag)
{
     if (flag)
         return new A();
       return new B();

}
Comment

PREVIOUS NEXT
Code Example
Csharp :: C# unit test exception using attribrute 
Csharp :: c# delete files 
Csharp :: unity scroll rect to bottom 
Csharp :: new datetime c# 
Csharp :: c# remove time in datetime 
Csharp :: Failed to generate swagger file. Error dotnet swagger tofile --serializeasv2 --output 
Csharp :: ignore ssl c# 
Csharp :: System.Data.Entity.Core.EntityException: The underlying provider failed on Open 
Csharp :: listbox items to string c# 
Csharp :: c# callback action lambda 
Csharp :: ??= mean C# 
Csharp :: animation setbool unity 
Csharp :: c# get a value from value tuple list 
Csharp :: password regex asp.net 
Csharp :: sealed method in c# 
Csharp :: jagged array to 2d array c# 
Csharp :: c# get smallest of 3 numbers 
Csharp :: how to cut a string in c# 
Csharp :: global exception handler c# 
Csharp :: ArgumentException: Input Key named: Fire1 is unknown 
Csharp :: c# list any retun indec 
Csharp :: xamarin set environment variables 
Csharp :: store data between razor pages 
Csharp :: dynamic add event control c# 
Csharp :: how to fade c# form 
Csharp :: c# loop through queue 
Csharp :: wpf get name of clicked element 
Csharp :: how to stream video from vlc in c# 
Csharp :: 2d array 
Csharp :: Palindromic substrings 
ADD CONTENT
Topic
Content
Source link
Name
7+3 =