Click here to Skip to main content
15,888,351 members
Home / Discussions / C#
   

C#

 
GeneralRe: Why is float to double conversion uniquely terrible? Pin
Eric Lynch3-Mar-19 18:28
Eric Lynch3-Mar-19 18:28 
GeneralRe: Why is float to double conversion uniquely terrible? Pin
Peter_in_27803-Mar-19 3:23
professionalPeter_in_27803-Mar-19 3:23 
GeneralRe: Why is float to double conversion uniquely terrible? Pin
Eric Lynch3-Mar-19 4:58
Eric Lynch3-Mar-19 4:58 
GeneralRe: Why is float to double conversion uniquely terrible? Pin
Eric Lynch3-Mar-19 7:07
Eric Lynch3-Mar-19 7:07 
GeneralRe: Why is float to double conversion uniquely terrible? Pin
Richard Deeming5-Mar-19 2:15
mveRichard Deeming5-Mar-19 2:15 
QuestionC# how to get all files from a directory that is inside the current project Pin
dolfijn300027-Feb-19 10:26
dolfijn300027-Feb-19 10:26 
AnswerRe: C# how to get all files from a directory that is inside the current project PinPopular
Richard Deeming27-Feb-19 10:43
mveRichard Deeming27-Feb-19 10:43 
QuestionForce Interface Implementation in Derived Classes? Pin
pr1mem0ver27-Feb-19 6:51
pr1mem0ver27-Feb-19 6:51 
Perhaps I want something that is impossible... but thought I would ask anyway because I cannot find a way to do this... and it seems like it should be possible.

I want to force the definition of a method in all subclasses without that method being virtual. (I don't want a virtual table and lookup to be necessary). Normally one would do this with an interface. The problem is that I also need to define a property with an explicit definition. Normally that is done with an abstract class (which is the only reason I need to define one) An example is illustrated below. The problem I am running into is that if I inherit the interface in the abstract class, none of the sub-classes require the "NeededFunction" to be implemented, which is counter to what I want. If I don't implement the method in the abstract class however, it gives me an error. Is there a way to do this... basically I want the derived classes to implement the "NeededFunction" rather than the abstract class (without them being virtual for performance reasons). I know I can have every derived class implement the interface instead but that seems needlessly redundant.

C#
interface IMyFunctionInterface
{
	void NeededFunction(object state);
}

internal abstract class MyBaseImplementation : IMyFunctionInterface
{
	internal MyRelevantProperty { get; protected set; }
	public void NeededFunction(object state) 
	{ 
		//defined here only to satisfy interface requirements... 
	  	//want to force this to be implemented in each subclass rather than here
	}
}

internal class Implementation1 : MyBaseImplementation
{
	public void NeededFunction(object state)... // want to define this here instead of in base class
}


modified 27-Feb-19 13:05pm.

AnswerRe: Force Interface Implementation in Derived Classes? Pin
Richard Deeming27-Feb-19 7:51
mveRichard Deeming27-Feb-19 7:51 
GeneralRe: Force Interface Implementation in Derived Classes? Pin
pr1mem0ver28-Feb-19 1:25
pr1mem0ver28-Feb-19 1:25 
GeneralRe: Force Interface Implementation in Derived Classes? Pin
Richard Deeming28-Feb-19 1:36
mveRichard Deeming28-Feb-19 1:36 
AnswerRe: Force Interface Implementation in Derived Classes? Pin
Gerry Schmitz27-Feb-19 13:51
mveGerry Schmitz27-Feb-19 13:51 
GeneralRe: Force Interface Implementation in Derived Classes? Pin
pr1mem0ver28-Feb-19 1:41
pr1mem0ver28-Feb-19 1:41 
QuestionA problem with Lists / Arrays Pin
Nikol Dimitrova25-Feb-19 9:34
Nikol Dimitrova25-Feb-19 9:34 
AnswerRe: A problem with Lists / Arrays Pin
Richard Deeming25-Feb-19 10:56
mveRichard Deeming25-Feb-19 10:56 
Questionalign columns headers with cells values in a text file that exported from a datagridview in c# Pin
Member 1332584624-Feb-19 7:20
Member 1332584624-Feb-19 7:20 
AnswerRe: align columns headers with cells values in a text file that exported from a datagridview in c# Pin
Gerry Schmitz24-Feb-19 8:46
mveGerry Schmitz24-Feb-19 8:46 
GeneralRe: align columns headers with cells values in a text file that exported from a datagridview in c# Pin
Member 1332584624-Feb-19 13:23
Member 1332584624-Feb-19 13:23 
QuestionTextBox setting caret at end of text Pin
ormonds23-Feb-19 13:21
ormonds23-Feb-19 13:21 
AnswerRe: TextBox setting caret at end of text Pin
Dave Kreskowiak23-Feb-19 13:56
mveDave Kreskowiak23-Feb-19 13:56 
GeneralRe: TextBox setting caret at end of text Pin
ormonds23-Feb-19 14:20
ormonds23-Feb-19 14:20 
GeneralRe: TextBox setting caret at end of text Pin
Mycroft Holmes23-Feb-19 14:59
professionalMycroft Holmes23-Feb-19 14:59 
GeneralRe: TextBox setting caret at end of text Pin
Dave Kreskowiak23-Feb-19 15:16
mveDave Kreskowiak23-Feb-19 15:16 
AnswerRe: TextBox setting caret at end of text Pin
BillWoodruff23-Feb-19 20:31
professionalBillWoodruff23-Feb-19 20:31 
QuestionAPI to call bitcoin price Pin
Member 1416032523-Feb-19 4:25
Member 1416032523-Feb-19 4:25 

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.