Data Types
ASP.NET web services can use any CLR-supported primitive data type as a parameter or a return value. Table 15-2 summarizes the valid types.
Table 15-2. CLR-supported primitive data types
Type |
Description |
---|---|
|
1-byte unsigned integer |
|
2-byte signed integer |
|
4-byte signed integer |
|
8-byte signed integer |
|
4-byte floating point |
|
8-byte floating point |
|
16-byte floating point |
|
True/false |
|
Single Unicode character |
|
Sequence of Unicode characters |
|
Represents dates and times |
|
Any type |
In addition to the primitive data types, you can use arrays and ArrayLists
of the primitive types. Since data is passed between a web service and its clients using XML, whatever is used as either a parameter or return value must be represented in an XML schema or XSD.
Arrays
The examples shown so far in this chapter have used simple primitive types, such as strings and numbers, as parameters and return values. You can also use an array of primitive types as in the code shown here:
[WebMethod] public string[] GetArray() { string[] TestArray = {"a","b","c"}; return TestArray; }
The main limitation of using arrays, of course, is that you must know the number of elements at design time. If the number of elements is dynamic, then an ArrayList
will be called for. If an ArrayList
is used in the web service, it will be converted to an object array when the web service description is created. The client ...
Get Programming ASP.NET, 3rd Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.