Click here to Skip to main content
15,915,094 members
Home / Discussions / C#
   

C#

 
GeneralRe: IDisposable Pin
Heath Stewart30-Mar-04 10:17
protectorHeath Stewart30-Mar-04 10:17 
GeneralRe: IDisposable Pin
blackthunder00130-Mar-04 14:32
blackthunder00130-Mar-04 14:32 
GeneralRe: IDisposable Pin
Heath Stewart30-Mar-04 16:24
protectorHeath Stewart30-Mar-04 16:24 
QuestionHow do i import/use these dll's ? Pin
mihaimarinescu30-Mar-04 8:53
mihaimarinescu30-Mar-04 8:53 
AnswerRe: How do i import/use these dll's ? Pin
Heath Stewart30-Mar-04 9:38
protectorHeath Stewart30-Mar-04 9:38 
AnswerRe: How do i import/use these dll's ? Pin
Dave Kreskowiak30-Mar-04 9:39
mveDave Kreskowiak30-Mar-04 9:39 
GeneralCasting again - from parent to child Pin
Grep30-Mar-04 8:31
Grep30-Mar-04 8:31 
GeneralRe: Casting again - from parent to child Pin
Heath Stewart30-Mar-04 9:43
protectorHeath Stewart30-Mar-04 9:43 
The return, of course, is a Socket, not an SSocket, so you can't cast because it isn't that type. Casting to a parent always works, and in a polymorphic design if a method returns the parent class of a deriviative object but the object is a type of the derivative, you can then cast down, like so:
public class Parent
{
  public abstract Parent ReturnMe();
  static void Main()
  {
    Child child = (Child)new Parent();
    Console.WriteLine(child.ReturnMe()); // Writes "Child" to console.
  }
}
public class Child : Parent
{
  public override Parent ReturnMe()
  {
    return this;
  }
}
That's not the case here.

I recommend encpasulating the Socket instead of deriving from it. This also gives you more control over what the caller can do so you only expose what you want to expose.

 

Microsoft MVP, Visual C#
My Articles
GeneralRe: Casting again - from parent to child Pin
Grep30-Mar-04 9:59
Grep30-Mar-04 9:59 
GeneralRe: Casting again - from parent to child Pin
Heath Stewart30-Mar-04 10:08
protectorHeath Stewart30-Mar-04 10:08 
QuestionIs this a pointer operation ? Pin
Andres Coder30-Mar-04 8:28
Andres Coder30-Mar-04 8:28 
AnswerRe: Is this a pointer operation ? Pin
leppie30-Mar-04 8:50
leppie30-Mar-04 8:50 
AnswerRe: Is this a pointer operation ? Pin
Andy Wieberneit30-Mar-04 11:09
Andy Wieberneit30-Mar-04 11:09 
AnswerRe: Is this a pointer operation ? Pin
Bryan White31-Mar-04 9:01
Bryan White31-Mar-04 9:01 
GeneralC# time to C++ time_t Pin
goodpilot30-Mar-04 8:22
goodpilot30-Mar-04 8:22 
GeneralRe: C# time to C++ time_t Pin
Heath Stewart30-Mar-04 9:31
protectorHeath Stewart30-Mar-04 9:31 
GeneralRe: C# time to C++ time_t Pin
goodpilot30-Mar-04 10:19
goodpilot30-Mar-04 10:19 
GeneralRe: C# time to C++ time_t Pin
Bryan White31-Mar-04 9:11
Bryan White31-Mar-04 9:11 
GeneralRe: C# time to C++ time_t Pin
Heath Stewart31-Mar-04 9:17
protectorHeath Stewart31-Mar-04 9:17 
GeneralWriting and closing files Pin
Member 70426330-Mar-04 7:32
Member 70426330-Mar-04 7:32 
GeneralRe: Writing and closing files Pin
leppie30-Mar-04 7:46
leppie30-Mar-04 7:46 
GeneralRe: Writing and closing files Pin
Member 70426330-Mar-04 7:53
Member 70426330-Mar-04 7:53 
GeneralRe: Writing and closing files Pin
Heath Stewart30-Mar-04 8:51
protectorHeath Stewart30-Mar-04 8:51 
GeneralMP3 Streaming sdk Pin
refahn30-Mar-04 7:32
refahn30-Mar-04 7:32 
GeneralJoint Collection Project Pin
Jonathan de Halleux30-Mar-04 7:13
Jonathan de Halleux30-Mar-04 7:13 

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.