object - Are you missing a using directive or an assembly reference in c# on creating Obect of different class -
i new c# (had c++ background before).
i have class "myclass" creates object of class "symbols" in same namespace. create object of class "symbols" in order define function "add_symbol()" called "myclass".
in c++ quiet easy:
void nameoftheclass::nameofthefunction() { }
but don't know how in c#. tried code below , got following error(see @ last).
using system; using system.io; using system.collections.generic; using system.linq; using system.text; namespace shekhar_final { public class symbols { public void add_symbol(byte processingvalue) //called myclass { console.writeline(processingvalue); } } public class myclass { public static void main(string[] args) { symbols objsym =new objsym(); //here error using (var stream = new binaryreader(system.io.file.openread(args[0]))) { while (stream.basestream.position < stream.basestream.length) { byte processingvalue = stream.readbyte(); objsym.add_symbol(processingvalue); //this function called defined in symbol class } } } } }
the error (i have pointed line causing error in code) :
error cs0246: type or namespace name `objsym' not found. missing using directive or assembly reference?
please me in removing error , guidance appreciated because new c#, thanks
instead of
symbols objsym = new objsym();
you should initialize class:
symbols objsym = new symbols();
.
right trying initialize variable , not class.
Comments
Post a Comment