Click here to Skip to main content
15,796,982 members
Home / Discussions / C#
   

C#

 
AnswerRe: Problem to read Com port with while loop? Pin
Raphael Adeniji11-Apr-22 3:39
Raphael Adeniji11-Apr-22 3:39 
AnswerRe: Problem to read Com port with while loop? Pin
Luc Pattyn11-Apr-22 13:21
sitebuilderLuc Pattyn11-Apr-22 13:21 
QuestionMigrating Web Applications (Web Forms) to Dot Net Core Blazor Applications Pin
Raphael Adeniji10-Apr-22 20:44
Raphael Adeniji10-Apr-22 20:44 
AnswerRe: Migrating Web Applications (Web Forms) to Dot Net Core Blazor Applications Pin
Richard MacCutchan10-Apr-22 22:28
mveRichard MacCutchan10-Apr-22 22:28 
GeneralRe: Migrating Web Applications (Web Forms) to Dot Net Core Blazor Applications Pin
Raphael Adeniji11-Apr-22 3:28
Raphael Adeniji11-Apr-22 3:28 
GeneralRe: Migrating Web Applications (Web Forms) to Dot Net Core Blazor Applications Pin
Richard MacCutchan11-Apr-22 7:06
mveRichard MacCutchan11-Apr-22 7:06 
QuestionWill calling a new method/property work if called on a "base" abstract object Pin
pr1mem0ver9-Apr-22 19:42
pr1mem0ver9-Apr-22 19:42 
AnswerRe: Will calling a new method/property work if called on a "base" abstract object Pin
pr1mem0ver9-Apr-22 21:20
pr1mem0ver9-Apr-22 21:20 
Nevermind. Found the answer myself with a few test classes:

C#
public class CoreClass
{
	public int Value { get { return 1; } }
}

public class ClassA : CoreClass
{
	public new int Value { get { return 2; } }
}

public class ClassB : CoreClass
{
	public new int Value { get { return 3; } }
}

public class ClassC : CoreClass
{
	public new int Value { get { return 4; } }
}

public class ClassD : CoreClass
{
	public new int Value { get { return 5; } }
}

public class ContainerClass
{
	public CoreClass CoreObject { get; set; }
	public int CoreValue { get { return CoreObject.Value; } }

	public ContainerClass(CoreClass instance) { CoreObject = instance; }
}

static void Main(string[] args)
{
	ContainerClass a = new ContainerClass(new ClassA());
	ContainerClass b = new ContainerClass(new ClassB());
	ContainerClass c = new ContainerClass(new ClassC());
	ContainerClass d = new ContainerClass(new ClassD());

	int av = a.CoreValue;
	int bv = b.CoreValue;
	int cv = c.CoreValue;
	int dv = d.CoreValue;	
}


Bummer... all the int values in Main were 1. So looks like it calls the base class method and not the derived one. Looks like I will need to try a different approach.
GeneralRe: Will calling a new method/property work if called on a "base" abstract object Pin
OriginalGriff9-Apr-22 23:16
mvaOriginalGriff9-Apr-22 23:16 
GeneralRe: Will calling a new method/property work if called on a "base" abstract object Pin
pr1mem0ver10-Apr-22 7:10
pr1mem0ver10-Apr-22 7:10 
QuestionProblem with BackgroundWorker component? Pin
Member 140558797-Apr-22 2:23
Member 140558797-Apr-22 2:23 
AnswerRe: Problem with BackgroundWorker component? Pin
Richard MacCutchan7-Apr-22 2:41
mveRichard MacCutchan7-Apr-22 2:41 
AnswerRe: Problem with BackgroundWorker component? Pin
Luc Pattyn7-Apr-22 7:30
sitebuilderLuc Pattyn7-Apr-22 7:30 
AnswerRe: Problem with BackgroundWorker component? Pin
Gerry Schmitz7-Apr-22 7:30
mveGerry Schmitz7-Apr-22 7:30 
QuestionC# Exception: An object reference does not point to an instance of an objec Pin
Member 155831391-Apr-22 1:29
Member 155831391-Apr-22 1:29 
AnswerRe: C# Exception: An object reference does not point to an instance of an objec Pin
Richard Deeming1-Apr-22 1:51
mveRichard Deeming1-Apr-22 1:51 
AnswerRe: C# Exception: An object reference does not point to an instance of an objec Pin
OriginalGriff1-Apr-22 1:53
mvaOriginalGriff1-Apr-22 1:53 
AnswerRe: C# Exception: An object reference does not point to an instance of an objec Pin
Richard MacCutchan1-Apr-22 2:07
mveRichard MacCutchan1-Apr-22 2:07 
GeneralRe: C# Exception: An object reference does not point to an instance of an objec Pin
Dave Kreskowiak1-Apr-22 3:12
mveDave Kreskowiak1-Apr-22 3:12 
GeneralRe: C# Exception: An object reference does not point to an instance of an objec Pin
Gary R. Wheeler2-Apr-22 4:21
Gary R. Wheeler2-Apr-22 4:21 
GeneralRe: C# Exception: An object reference does not point to an instance of an objec Pin
Pete O'Hanlon5-Apr-22 5:03
subeditorPete O'Hanlon5-Apr-22 5:03 
AnswerRe: C# Exception: An object reference does not point to an instance of an objec Pin
Raphael Adeniji10-Apr-22 15:20
Raphael Adeniji10-Apr-22 15:20 
AnswerRe: C# Exception: An object reference does not point to an instance of an objec Pin
Raphael Adeniji12-Apr-22 4:36
Raphael Adeniji12-Apr-22 4:36 
QuestionAccess Android Tablet from C# Pin
Kevin Marois30-Mar-22 19:23
professionalKevin Marois30-Mar-22 19:23 
AnswerRe: Access Android Tablet from C# Pin
Richard MacCutchan30-Mar-22 23:30
mveRichard MacCutchan30-Mar-22 23:30 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.