Có 20+ tài liệu thuộc chủ đề "tư liệu lập trình"
tailieu.vn Xem trực tuyến Tải xuống
Consider the following struct that represents a position on a screen as an (X, Y) coordinate pair:. this.X = rangeCheckedX(x);. this.Y = rangeCheckedY(y);. public int X;. public int Y;. private static int rangeCheckedX(int x). if (x <. throw new ArgumentOutOfRangeException("X");. private static int rangeCheckedY(int y). if (y <. throw new ArgumentOutOfRangeException("Y");. The problem with this struct is that it does...
tailieu.vn Xem trực tuyến Tải xuống
Consider the EmployeeForm.aspx page of the Honest John Web site again. The employee ID should be a positive integer.. In a Windows Forms application, you would use the Validating event to ensure the user typed something into the First Name and Last Name text boxes and that the employee ID value was numeric. This event runs the next time the...
tailieu.vn Xem trực tuyến Tải xuống
A method or field is said to be private if it is accessible only from the inside of the class. A method or field is said to be public if it is accessible from both the inside and the outside of the class. it is not accessible from outside the class.
tailieu.vn Xem trực tuyến Tải xuống
Errors can occur at almost any stage when a program runs, so how do you detect them and attempt to recover? Over the years, a number of. A typical approach adopted by older systems such as Unix involved arranging for the operating system to set a special global variable whenever a method failed. Then, after each call to a method,...
tailieu.vn Xem trực tuyến Tải xuống
Abstract Classes. The IToken interface could be implemented by many different classes, one for each type of token in a C# source file: IdentifierToken, KeywordToken, LiteralToken,. (You might also have classes for comments and white space.) In situations such as this, it's quite common for parts of the derived classes to share common implementations. For example, the duplication in the...
tailieu.vn Xem trực tuyến Tải xuống
Adding Controls to the Form. To make the form useful, you need to add controls and write some code of your own. In the next exercise, you will add controls to the form that allow a user to input member details. You will use a variety of different controls, each suited to a particular type of data entry.. You will...
tailieu.vn Xem trực tuyến Tải xuống
You can use the Visual Studio 2005 integrated development environment (IDE) and the menu editor to create a menu graphically. MenuStrip object (MenuStrip is a class defined in the Windows Forms library), and then add ToolStripMenuItem objects to it (ToolStripMenuItem is another class in the. In the following exercise, you will use the graphical approach to create menus for the...
tailieu.vn Xem trực tuyến Tải xuống
You decide to create a form like the one shown in the following graphic.. You need to ensure that the user's input is consistent. the title (Mr, Mrs, Miss, or Ms) must match the selected gender (Male or Female), and vice versa.. In the following exercises, you will examine the Customer Maintenance application and run it to see how easily...
tailieu.vn Xem trực tuyến Tải xuống
You have seen in some of the examples that you can create a variable inside a method.. subsequent statements in the same method can then use the variable. To put it another way, the scope of a variable is simply the region of the program in which that variable is usable. The scope of an identifier (of a variable or...
tailieu.vn Xem trực tuyến Tải xuống
Building the ProductService Web Service. In this chapter, you will create the ProductService Web service. This Web service will expose two Web methods. The first method will allow the user to calculate the cost of buying a specified quantity of a particular product in the Northwind Traders database, and the second method will take the name of a product and...
tailieu.vn Xem trực tuyến Tải xuống
If the method requires information (as specified by its parameters), you must supply the. If the method returns information (as specified by its return type), you should arrange to capture this information somehow.. Specifying the Method Call Syntax. The methodName must exactly match the name of the method you're calling.. The argumentList supplies the optional information that the method accepts....
tailieu.vn Xem trực tuyến Tải xuống
Declaring Increment and Decrement Operators. C# allows you to declare your own version of the increment. and decrement. they must be public, they must be static, and they must be unary. Here is the increment operator for the Hour struct:. public static Hour operator++ (Hour arg). arg.value++;. The increment and decrement operators are unique in that they can be used...
tailieu.vn Xem trực tuyến Tải xuống
In the following exercises, you will define and use a class that represents a binary tree.. The two sub-trees are conventionally called the left sub-tree and the right sub-tree because they are typically depicted to the left and right of the node respectively. If you start with an unordered sequence of objects of the same type, you can use them...
tailieu.vn Xem trực tuyến Tải xuống
Declaring an Event. You declare an event in a class intended to act as an event source. An event source is usually a class that monitors its environment, and raises an event when something significant happens. In the automated factory, an event source could be a class that monitors the temperature of each machine. An event maintains a list of...
tailieu.vn Xem trực tuyến Tải xuống
In the world of programming (unlike in the real world), everything is black or white, right or wrong, true or false. For example, if you create an integer variable called x, assign the value 99 to x, and then ask, “Does x contain the value 99. the answer is definitely true.. If you ask, “Is x less than 10. the...
tailieu.vn Xem trực tuyến Tải xuống
Remember that all arrays in C# are actually instances of the System.Array class. The GetEnumerator method returns an enumerator object that implements the. System.Collections.IEnumerator interface. The enumerator object is used for stepping through (enumerating) the elements of the collection. The IEnumerator interface itself specifies the following property and methods:. Think of an enumerator as a pointer pointing to elements in...
tailieu.vn Xem trực tuyến Tải xuống
encapsulate your methods and data inside a class, the class forms a boundary to the outside world. Fields (such as radius) and methods (such as Area) defined in the class can be seen by other methods inside the class, but not by the outside world—they are private to the class. A method or field is said to be private if...
tailieu.vn Xem trực tuyến Tải xuống
You have seen in some of the examples that you can create a variable inside a method. The variable comes into existence at the point where a statement defines it, and subsequent statements in the same method can then use the variable. To put it another way, the scope of a variable is simply the region of the program in...
tailieu.vn Xem trực tuyến Tải xuống
Remember that i is a value type and it exists in the stack. If the method requires information (as specified by its parameters), you must supply the. If the method returns information (as specified by its return type), you should arrange to capture this information somehow.. Specifying the Method Call Syntax. The methodName must exactly match the name of the...
tailieu.vn Xem trực tuyến Tải xuống
When you declare an int variable, the compiler generates code that allocates a block of memory big enough to hold an integer. A statement that assigns a value (such as 42) to the int causes the value to be copied to this block of memory.. When you declare a Circle variable, the compiler does not generate code that allocates a...