bpayne111 Posted May 7, 2004 Posted May 7, 2004 public interface myPlug { void Initialize(test.IHost host); readonly string Name(); void Go(object[] objs); } blue squiggly on 'Name' "The modifier 'readonly' is not valid for this item" Why? what's wrong with this? i feel small Brandon Quote i'm not lazy i'm just resting before i get tired.
Joe Mamma Posted May 7, 2004 Posted May 7, 2004 public interface myPlug { void Initialize(test.IHost host); readonly string Name(); void Go(object[] objs); } blue squiggly on 'Name' "The modifier 'readonly' is not valid for this item" Why? what's wrong with this? i feel small Brandon if I understand correctly want you really want is a read only property in your interface. . . public interface myPlug { void Initialize(test.IHost host); string Name { get{} }; void Go(object[] objs); } Quote Joe Mamma Amendment 4: The right of the people to be secure in their persons, houses, papers, and effects, against unreasonable searches and seizures, shall not be violated, and no warrants shall issue, but upon probable cause, supported by oath or affirmation, and particularly describing the place to be searched, and the persons or things to be seized. Amendment 9: The enumeration in the Constitution, of certain rights, shall not be construed to deny or disparage others retained by the people.
bpayne111 Posted May 7, 2004 Author Posted May 7, 2004 thansk for you your help... i figured it out after some more time i just used a function instead of a readonly property... DOH! Quote i'm not lazy i'm just resting before i get tired.
Joe Mamma Posted May 7, 2004 Posted May 7, 2004 thansk for you your help... i figured it out after some more time i just used a function instead of a readonly property... DOH! yes that will work. . . but the convention for Name is a property. . . I mean you dont execute string s = myObj.Name(); do you? usually it is string s = myObj.Name; just a matter of style Quote Joe Mamma Amendment 4: The right of the people to be secure in their persons, houses, papers, and effects, against unreasonable searches and seizures, shall not be violated, and no warrants shall issue, but upon probable cause, supported by oath or affirmation, and particularly describing the place to be searched, and the persons or things to be seized. Amendment 9: The enumeration in the Constitution, of certain rights, shall not be construed to deny or disparage others retained by the people.
bpayne111 Posted May 7, 2004 Author Posted May 7, 2004 yes i think you are right... i will probably change it thanks brandon Quote i'm not lazy i'm just resting before i get tired.
bpayne111 Posted May 8, 2004 Author Posted May 8, 2004 public interface myPlug { void Initialize(test.IHost host); string Name { get{} }; void Go(object[] objs); } joe i was not allowed to create a readonly property this way for Name. there has to be a way to do it... arrrg thanks brandon Quote i'm not lazy i'm just resting before i get tired.
Administrators PlausiblyDamp Posted May 8, 2004 Administrators Posted May 8, 2004 Did you get a particular error when trying that? The code looks okay.... Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
bpayne111 Posted May 9, 2004 Author Posted May 9, 2004 it wont' allow the semicolon... if i remove that, well it obviously doesn't work in my interface ... what's the deal? thanks for the help brandon Quote i'm not lazy i'm just resting before i get tired.
mooman_fl Posted May 9, 2004 Posted May 9, 2004 The proper code is as follows: [b][size=2][color=#0000ff]public [/b][/color][/size][size=2][color=#ff0000]interface [/color][/size][size=2][color=#000000]myPlug[/color] [/size][size=2][color=#006400]{ [/color][/size][size=2][color=#ff0000]void [/color][/size][b][size=2][color=#191970]Initialize[/b][/color][/size][size=2][color=#006400]([/color][/size][size=2][color=#000000]test[/color][/size][size=2][color=#006400].[/color][/size][size=2][color=#000000]IHost host[/color][/size][size=2][color=#006400]); [/color][/size][size=2][color=#ff0000]string [/color][/size][size=2][color=#000000]Name [/color][/size][size=2][color=#006400]{[/color][/size][size=2][color=#8b4513]get[/color][/size][size=2][color=#006400];} [/color][/size][size=2][color=#ff0000]void [/color][/size][b][size=2][color=#191970]Go[/b][/color][/size][size=2][color=#006400]([/color][/size][size=2][color=#ff0000]object[/color][/size][size=2][color=#006400][] [/color][/size][size=2][color=#000000]objs[/color][/size][size=2][color=#006400]); }[/color][/size] This is as reference from the MSDN documentation at http://msdn.microsoft.com/library/default.asp?url=/library/en-us/csref/html/vcrefTheInterfaceType.asp Quote "Programmers are tools for converting caffeine into code." Madcow Inventions -- Software for the Sanity Challenged.
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.