//Hi all just switching from c++ to c#.Can anyone help,with the question i have:
//this is a peace of code from c++ banking aplication
int ShowMenu(void);
void AddAccount(vector<CAccount*>& list);
void DisplayAccount (vector<CAccount*>& list);
void Lodgement (vector<CAccount*>& list);
void Withdroawal (vector<CAccount*>& list);
void InterestRate (vector<CAccount*>& list);
CAccount* findAccount (vector<CAccount*>string );
bool quit = false;
int _tmain(int argc, _TCHAR* argv[])
{
vector<CAccount*> list;
int option = 0;
do{
quit =false;
option =ShowMenu();
switch ( option )
{
case 1:
AddAccount(list);
break;
case 2:
DisplayAccount(list);
break;
case 3:
Lodgement(list);
break;
case 4:
Withdroawal(list);
break;
case 5:
InterestRate(list);
break;
case 6:
quit = true;
break;
default:
cout << "Invalid Entry, Please Try Again";
}
}while(!quit);
return 0;
}
//How to change c++ vector to c# and what #include should be?Thank you.
PulsarScript
0
Junior Poster
Recommended Answers
Jump to PostA List<T> in c# is the same as a vector<T> in C++.
cout would become Console.Write or WriteLine in C#.
Jump to PostIf you have a CAccount class, you don't need a pointer to that class just use List<CAcount>. In C# you seldom use pointers. The compiler does it for you. You still can use pointers but then, you have to mark the code with the
unsafe
keyword.
Jump to PostIn C# you can think of all classes as references (pointers)
Like ddanbe said above, if you really want the pointer, you can use the
unsafe
keyword and then use it like C++. A more safe way is to marshall it out into anIntPtr
object, but this is generally …
Jump to PostPerhaps you could specify everyting by function(method in C# talk) at the time. We (at least I) don't see all the things going on, please explain them.
Your AddAccount function seems rather easy this would be something likelist.Add(AnAcount);
Jump to PostOn line 207 of your previous post you have
List<Account> list = new List<Account>();
If CurrentAcount is another class you have to make a new List unless CurrentAcount is of type Account and you overloaded the consturtor in the Account class. Have to say goodnight now, see you in the …
All 42 Replies
ddanbe
2,724
Professional Procrastinator
Featured Poster
PulsarScript
0
Junior Poster
ddanbe
2,724
Professional Procrastinator
Featured Poster
Ketsuekiame
860
Master Poster
Featured Poster
ddanbe
commented:
Could not have explained it better.
+15
PulsarScript
0
Junior Poster
ddanbe
2,724
Professional Procrastinator
Featured Poster
PulsarScript
0
Junior Poster
ddanbe
2,724
Professional Procrastinator
Featured Poster
ddanbe
2,724
Professional Procrastinator
Featured Poster
PulsarScript
0
Junior Poster
ddanbe
2,724
Professional Procrastinator
Featured Poster
PulsarScript
0
Junior Poster
PulsarScript
0
Junior Poster
ddanbe
2,724
Professional Procrastinator
Featured Poster
ddanbe
2,724
Professional Procrastinator
Featured Poster
PulsarScript
0
Junior Poster
PulsarScript
0
Junior Poster
PulsarScript
0
Junior Poster
ddanbe
2,724
Professional Procrastinator
Featured Poster
PulsarScript
0
Junior Poster
PulsarScript
0
Junior Poster
ddanbe
2,724
Professional Procrastinator
Featured Poster
PulsarScript
0
Junior Poster
ddanbe
2,724
Professional Procrastinator
Featured Poster
PulsarScript
0
Junior Poster
PulsarScript
0
Junior Poster
PulsarScript
0
Junior Poster
ddanbe
2,724
Professional Procrastinator
Featured Poster
PulsarScript
0
Junior Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of 1.20 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.