Click here to Skip to main content
15,919,434 members
Home / Discussions / C#
   

C#

 
GeneralRe: Counting set bits Pin
PaleyX23-Feb-05 6:51
PaleyX23-Feb-05 6:51 
GeneralRe: Counting set bits Pin
Philip Fitzsimons23-Feb-05 6:59
Philip Fitzsimons23-Feb-05 6:59 
GeneralRe: Counting set bits Pin
PaleyX23-Feb-05 7:10
PaleyX23-Feb-05 7:10 
GeneralRe: Counting set bits Pin
Philip Fitzsimons23-Feb-05 7:15
Philip Fitzsimons23-Feb-05 7:15 
GeneralRe: Counting set bits Pin
PaleyX23-Feb-05 7:26
PaleyX23-Feb-05 7:26 
GeneralRe: Counting set bits Pin
Sebastian Schneider25-Feb-05 2:34
Sebastian Schneider25-Feb-05 2:34 
GeneralRe: Counting set bits Pin
PaleyX25-Feb-05 2:52
PaleyX25-Feb-05 2:52 
Generalfunctions with override and new keywords .... Pin
vchedalla23-Feb-05 5:10
vchedalla23-Feb-05 5:10 
Hi,

Could someone tell me the purpose/good situations where override and new keywords are used in function declaration.

I got the primary idea through versioning sample(given below for your reference). But I am sure,there is more value than what I can I understand through this sample.



Thanks
Vinay.



The sample :
--------------
//Copyright (C) 2000 Microsoft Corporation. All rights reserved.

// versioning.cs
// CS0114 expected
public class MyBase
{
public virtual string Meth1()
{
return "MyBase-Meth1";
}
public virtual string Meth2()
{
return "MyBase-Meth2";
}
public virtual string Meth3()
{
return "MyBase-Meth3";
}
}

class MyDerived : MyBase
{
// Overrides the virtual method Meth1 using the override keyword:
public override string Meth1()
{
return "MyDerived-Meth1";
}
// Explicitly hide the virtual method Meth2 using the new
// keyword:
public new string Meth2()
{
return "MyDerived-Meth2";
}
// Because no keyword is specified in the following declaration
// a warning will be issued to alert the programmer that
// the method hides the inherited member MyBase.Meth3():
public string Meth3()
{
return "MyDerived-Meth3";
}

public static void Main()
{
MyDerived mD = new MyDerived();
MyBase mB = (MyBase) mD;

System.Console.WriteLine(mB.Meth1());
System.Console.WriteLine(mB.Meth2());
System.Console.WriteLine(mB.Meth3());
}
}




GeneralRe: functions with override and new keywords .... Pin
turbochimp24-Feb-05 13:17
turbochimp24-Feb-05 13:17 
GeneralNewline in a TextBox Pin
pjholliday23-Feb-05 4:41
pjholliday23-Feb-05 4:41 
GeneralRe: Newline in a TextBox Pin
Sebastian Schneider23-Feb-05 4:58
Sebastian Schneider23-Feb-05 4:58 
GeneralRe: Newline in a TextBox Pin
Dave Kreskowiak23-Feb-05 5:29
mveDave Kreskowiak23-Feb-05 5:29 
GeneralRelease an object memory Pin
Sasuko23-Feb-05 4:27
Sasuko23-Feb-05 4:27 
GeneralRe: Release an object memory Pin
PaleyX23-Feb-05 5:09
PaleyX23-Feb-05 5:09 
GeneralRe: Release an object memory Pin
Dave Kreskowiak23-Feb-05 5:27
mveDave Kreskowiak23-Feb-05 5:27 
Generaldisplay a pic from the database Pin
Ahmed Galal23-Feb-05 4:05
Ahmed Galal23-Feb-05 4:05 
GeneralRe: display a pic from the database Pin
Sasuko23-Feb-05 4:31
Sasuko23-Feb-05 4:31 
GeneralRe: display a pic from the database Pin
Ahmed Galal23-Feb-05 6:54
Ahmed Galal23-Feb-05 6:54 
GeneralRe: display a pic from the database Pin
Ahmed Galal23-Feb-05 7:24
Ahmed Galal23-Feb-05 7:24 
GeneralSharing a Udp Port Pin
Zishan Haider23-Feb-05 4:02
Zishan Haider23-Feb-05 4:02 
GeneralRe: Sharing a Udp Port [EDITED] Pin
Dave Kreskowiak23-Feb-05 5:06
mveDave Kreskowiak23-Feb-05 5:06 
Generalcombobox and SelectedIndexChanged in 2.0 Pin
hartree23-Feb-05 1:46
hartree23-Feb-05 1:46 
GeneralPlease Helllllllllllllppppppp me :sigh: Pin
ahmed Za3roor23-Feb-05 1:35
ahmed Za3roor23-Feb-05 1:35 
GeneralRe: Please Helllllllllllllppppppp me :sigh: Pin
J4amieC23-Feb-05 2:04
J4amieC23-Feb-05 2:04 
Generalhtml or xml control/editbox (urgent) Pin
saima azeemi22-Feb-05 23:28
saima azeemi22-Feb-05 23:28 

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.