Click here to Skip to main content
15,907,000 members
Home / Discussions / C#
   

C#

 
GeneralRe: using separate codefiles Pin
Leslie Sanford8-Aug-06 19:05
Leslie Sanford8-Aug-06 19:05 
GeneralRe: using separate codefiles Pin
Glen Harvy8-Aug-06 21:21
Glen Harvy8-Aug-06 21:21 
AnswerRe: using separate codefiles Pin
Nader Elshehabi8-Aug-06 18:45
Nader Elshehabi8-Aug-06 18:45 
QuestionerrorProvider problem [modified] Pin
dustin108-Aug-06 13:25
dustin108-Aug-06 13:25 
AnswerRe: errorProvider problem Pin
stancrm8-Aug-06 22:14
stancrm8-Aug-06 22:14 
QuestionColor deviation algorithm... Pin
Shy Agam8-Aug-06 12:54
Shy Agam8-Aug-06 12:54 
QuestionExplorer bar type applications Pin
martin_hughes8-Aug-06 12:17
martin_hughes8-Aug-06 12:17 
QuestionCustom type casting Pin
Master Toothless One8-Aug-06 11:04
Master Toothless One8-Aug-06 11:04 
Say I have custom class foo. I also have a class bar that inherits from foo. I want a method that returns an instance of foo and then want to cast it to bar. How can I do this? I am working with C# 2.0. This is how I imagine it working, and it compiles this way, but I get a runtime error that bar cannot be converted into foo.

public class foo
{
public string someVariable;
}

public class bar : foo
{
public string someotherVariable;
}

public static foo SomeFunction()
{
foo returnVal = new foo();
return foo;
}

public static void AnotherFunction()
{
bar barVar = (bar) SomeFunction();
}

I am almost positive that this can be done, but I can't seem to remember how to do it. I don't want to pass in some kind of reference param or Type.


AnswerRe: Custom type casting Pin
led mike8-Aug-06 11:08
led mike8-Aug-06 11:08 
AnswerRe: Custom type casting [modified] Pin
Patricker8-Aug-06 12:00
Patricker8-Aug-06 12:00 
GeneralRe: Custom type casting Pin
Master Toothless One8-Aug-06 13:06
Master Toothless One8-Aug-06 13:06 
GeneralRe: Custom type casting Pin
Patricker8-Aug-06 13:44
Patricker8-Aug-06 13:44 
GeneralRe: Custom type casting [modified] Pin
Master Toothless One8-Aug-06 14:05
Master Toothless One8-Aug-06 14:05 
QuestionDatagrid column headers Pin
Naji.A8-Aug-06 9:51
Naji.A8-Aug-06 9:51 
AnswerRe: Datagrid column headers Pin
_AK_8-Aug-06 18:33
_AK_8-Aug-06 18:33 
GeneralRe: Datagrid column headers Pin
Naji.A9-Aug-06 16:26
Naji.A9-Aug-06 16:26 
Questionauto comboBox Pin
TAREQ F ABUZUHRI8-Aug-06 9:15
TAREQ F ABUZUHRI8-Aug-06 9:15 
AnswerRe: auto comboBox Pin
stancrm8-Aug-06 9:56
stancrm8-Aug-06 9:56 
Questionget files names from subdirectories Pin
Mridang Agarwalla8-Aug-06 7:57
Mridang Agarwalla8-Aug-06 7:57 
AnswerRe: get files names from subdirectories Pin
Stefan Troschuetz8-Aug-06 8:04
Stefan Troschuetz8-Aug-06 8:04 
AnswerRe: get files names from subdirectories Pin
Eric Dahlvang8-Aug-06 9:12
Eric Dahlvang8-Aug-06 9:12 
AnswerRe: get files names from subdirectories Pin
Ramasubramaniam8-Aug-06 10:23
Ramasubramaniam8-Aug-06 10:23 
QuestionListView.LabelEdit not working consistantly Pin
Dan Neely8-Aug-06 7:30
Dan Neely8-Aug-06 7:30 
Questionbase class? Pin
emil.muller8-Aug-06 7:27
emil.muller8-Aug-06 7:27 
AnswerRe: base class? Pin
Patricker8-Aug-06 12:03
Patricker8-Aug-06 12:03 

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.