Skip to content

Homework 4#4

Open
prashant1shukla wants to merge 4 commits intomainfrom
Homework-4
Open

Homework 4#4
prashant1shukla wants to merge 4 commits intomainfrom
Homework-4

Conversation

@prashant1shukla
Copy link
Owner

image

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should have created separate class for ListOperation and DictionaryOperation

Comment on lines +19 to +26
Console.WriteLine("Please enter a number from the given menu:");
Console.WriteLine("1. Add an element to the List.");
Console.WriteLine("2. Print all the elements present in the List.");
Console.WriteLine("3. Delete the last element from the List.");
Console.WriteLine("4. Delete the first element from the List.");
Console.WriteLine("5. Delete the middle element from the List.");
Console.WriteLine("6. Calculate the average of the elements present in the List.");
Console.WriteLine("7. Exit the application.");

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where are the dictionary operaitons????

{
case "1":
Console.Write("Enter a number to add to the List: ");
int numToAdd = Convert.ToInt32(Console.ReadLine());

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what if i enter 'a' in the console will it be converted? Or will it throw an error. Also did you looked into int.TryParse()?

Console.Write("Enter a number to add to the List: ");
int numToAdd = Convert.ToInt32(Console.ReadLine());
list.Add(numToAdd);
Menu();

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you are calling the Menu function again.. that means for every operation I will be creating another stack of function call... could have use a while(true) loop

break;
case "2":
Console.WriteLine("Elements in the List:");
foreach (var num in list)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

don't use var

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants