[Solved] How do you have user integer input in C#? [closed]

bThere are several problems in your code. On the fourth line you have int Test = Console.ReadLine(); Console.ReadLine() does not return an int, but a string. string Test = Console.ReadLine(); The name Test is not very descriptive and also violates the convention, that local variables should start with lower-case letter. So we can further improve the line to: string input = … Read more

[Solved] rewrite this code to use in .NET 2.0? [closed]

Shoulbn’t be that hard to figure out but here: //instead of var use the actual type FacebookClient client = new FacebookClient(); //again use the actual type IDictionary<string, object> me = (IDictionary<string, object>)client.Get(“me”); string firstName = (string)me[“first_name”]; //May use ‘me[“first_name”].ToString()’ string lastName = (string)me[“last_name”]; string email = (string)me[“email”]; solved rewrite this code to use in .NET … Read more

[Solved] My program is executing as expected but in the end I am an extra line called a segmentation fault near the output. Could someone see to it?

You’ve tagged this as c++ but it seems like you’re using entirely c.. So I’ll answer this as if it’s c. A segmentation fault occurs when you access memory that you don’t own. In this case you’re trying to print a character outside of the bounds of your string. (e.g. your string is len characters … Read more

[Solved] C Program not working

Why are you writing this line largest = nvalue; ? And your if-else if commands are totally wrong. Try this code: #include <stdio.h> int main(){ int largest = 0; int no1, no2, no3; printf(“Number1: “); scanf(“%d”, &no1); printf(“Number2: “); scanf(“%d”, &no2); printf(“Number3: “); scanf(“%d”, &no3); if ((no1 > no2) && (no1>no3)){ largest=no1; } else if … Read more

[Solved] Swapping two strings in C++

What does the arguments (char * &str1, char * &str2) specify in the swap function? they specify that parameters are of type reference to pointer to char. This means that function might change the value of the variable that was provided as argument to this function. What if they are replaced by (char &str1, char … Read more

[Solved] New to C#, can anyone explain to me how enums and setting variables for enums works? [closed]

An enum is basically a special type that lets you define named values. You’re creating a named type just as you would if you were defining a class. What your code is actually doing is first defining your enumerated type called States with all the possible named values, then declaring a variable “myState” using the … Read more

[Solved] Reassign reference returned by a method

It’s simply how Java is specified. From JLS Sec 15.26, the grammar of the assignment is given by: Assignment: LeftHandSide AssignmentOperator Expression LeftHandSide: ExpressionName FieldAccess ArrayAccess So the LHS has to be either a variable, a field or an array element. Anything else is invalid syntax. The reason why you can’t reassign a method’s return … Read more