Question

In: Computer Science

Discuss different ways user input can be validated using .Net and C#. How can you determine...

Discuss different ways user input can be validated using .Net and C#. How can you determine the best way to validate user input?

Discuss business problems that could be solved by the implementation of multithreading and asynchronous processing.

explain how "Optimize Applications with Multithreading implementation discussed can improve your C# code.

Solutions

Expert Solution

`Hey,

Note: Brother if you have any queries related the answer please do comment. I would be very happy to resolve all your queries.

1)

"To detect an error while you are parsing an int, you can use the int.TryParse(someString, out result) method. It takes a stringthat you want to convert (or parse) to an int and the result as a parameter. The out keyword in our example means that the result of this method will be written to the second method parameter which we called result. The output of the method is a bool value that indicates whether it was possible to parse the input as an int. Take a look at this example:

Console.WriteLine("Input your age");
var ageAsString = Console.ReadLine();

int age;
bool parseSuccess = int.TryParse(ageAsString, out age);

if (parseSuccess)
    Console.WriteLine($"Your age is: {age}");
else
    Console.WriteLine("This is not a number!");

So, like int we can do for any data type offered by c#

2)

In mobile applications to prevent the freezing of the screen, and give the customer the impression that the process is taking actions visually, but it’s usually not. Literally speaking, when an application asks for data (from a database, webservice, etc.), it has to wait until that service replies. All of the fancy gestures that are usually present in applications happen because of async calls to the services at the same time as entertaining the user with some logo or messaging. The amount of resources used at this time is much higher than normal app usage and ultimately, with lots of refreshes, users’ memory suffers.

There are work-arounds, and async is necessary in instances such as preloading data when the app first begins. In other instances, though, it’s cliché and often to the detriment of the users’ device to utilize async so heavily.

3)

For a long time, most programming applications (except for embedded system programs) were single-threaded. That means there was only one thread in the entire application. You could never do computation A until completing computation B. A program starts at step 1 and continues sequentially (step 2, step 3, step 4) until it hits the final step (call it step 10). A multithreaded application allows you to run several threads, each thread running in its own process. So theoretically you can run step 1 in one thread and at the same time run step 2 in another thread. At the same time you could run step 3 in its own thread, and even step 4 in its own thread. Hence step 1, step 2, step 3, and step 4 would run concurrently. Theoretically, if all four steps took about the same time, you could finish your program in a quarter of the time it takes to run a single thread (assuming you had a 4 processor machine).

Kindly revert for any queries

Thanks.


Related Solutions

Determine how performance will be validated using the Lewin's model in 200 words and one peer...
Determine how performance will be validated using the Lewin's model in 200 words and one peer reviewed reference.
Using C++ Create a program that asks the user to input a string value and then...
Using C++ Create a program that asks the user to input a string value and then outputs the string in the Pig Latin form. - If the string begins with a vowel, add the string "-way" at the end of the string. For “eye”, it will be “eye-way”. - If the string does not begin with a vowel, first add "-" at the end of the string. Then rotate the string one character at a time; that is, move the...
In c++, Can anyone make these code int user input as user have to put all...
In c++, Can anyone make these code int user input as user have to put all the amount. int main()    {        Polygon p1(3,4,4.5,5.5);        Polygon p2(4,4,5.5,6.5);        Polygon p3(5,4,6.5,7.5);               cout<<"Area of Polygon#1:"<<p1.getArea()<<endl;        cout<<"Perimeter of Polygon#1:"<<p1.getPerimeter()<<endl;               cout<<"\nArea of Polygon#2:"<<p2.getArea()<<endl;        cout<<"Perimeter of Polygon#2:"<<p2.getPerimeter()<<endl;               cout<<"\nArea of Polygon#3:"<<p3.getArea()<<endl;        cout<<"Perimeter of Polygon#3:"<<p3.getPerimeter()<<endl;                         return 0;     ...
C++ How do you make a 2d array with a user input. For example, the row...
C++ How do you make a 2d array with a user input. For example, the row and columns of the 2d array will be the same so the program can create a square matrix.
Program using java Take user input and give corresponding output. A user is considering different options...
Program using java Take user input and give corresponding output. A user is considering different options of operating air conditioning. Depending on room temperature (here, room temperature is given by user), this program should give different instructions. There are three scenarios. - If temperature is above 90, the program should output “cooling”. -If the temperature is below 70, the program should output “heating”. -Otherwise, the program should output “stopped”. For example, if user enters “95”, this is how the program...
using C language Create a bitwise calculator that ask user for input two input, first int,...
using C language Create a bitwise calculator that ask user for input two input, first int, bitwise operation, second int (i.e 5 & 9) only those bitwise operation are allowed: & ~ ^ | << >>. If user uses wrong operators stop program and ask again. Convert the first int and second int into 8 BITS binary (00000000) and use bitwise operator given by user to either AND, OR, XOR, etc (ie 1001 & 1111)
Using forms in Access lets you customize how you want to capture input from the user...
Using forms in Access lets you customize how you want to capture input from the user and screen the data if needed. If you were user entering data for a report, what are some of the things that make it easy for you to complete your task?
Without using formulas, explain how you can determine each of the following: c. If you have...
Without using formulas, explain how you can determine each of the following: c. If you have 10 people, how many different committees of 3 people can be formed for the offices of president, vice-president, and secretary? d. Does order matter or not for part c? Explain.
Write a C++ program using separate void which asks the user to input side of a...
Write a C++ program using separate void which asks the user to input side of a square, radius of a circle , height and base of a triangle and finds the area of squares, circles and triangles. Then using main function display the area of square, circle and triangle
CODE IN C PLEASE Ask for user to input 4 different numbers Use pointers in calculations...
CODE IN C PLEASE Ask for user to input 4 different numbers Use pointers in calculations instead of variables to calculate the sum of those 4 numbers Print the sum Use a pointer to a pointer for print operation
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT