vs.net 2003 中MSDN的问题
我安装了Visual Studio .NET 2003.习惯了用VC6,现在竟然不会用.net的MSDN
MSDN里面怎么搜索CString都搜不到呀?
是不是我没安装好? --------------------编程问答-------------------- 人品问题
--------------------编程问答-------------------- MSDN2005
-------------------------------------------
MFC Library Reference
Basic CString Operations
See Also
Language Filter: All Language Filter: Multiple Language Filter: Visual Basic Language Filter: C# Language Filter: C++ Language Filter: J# Language Filter: JScript
Visual Basic (Declaration)
Visual Basic (Usage)
C#
C++
J#
JScript
This article explains basic CString operations, including:
Creating CString objects from standard C literal strings
Accessing individual characters in a CString
Concatenating two CString objects
Comparing CString objects
The CString class provides member functions and overloaded operators that duplicate and, in some cases, surpass the string services of the C run-time libraries (for example, strcat).
Creating CString Objects from Standard C Literal Strings
You can assign C-style literal strings to a CString just as you can assign one CString object to another:
Assign the value of a C literal string to a CString object:
Copy Code
CString myString = "This is a test";
Assign the value of one CString to another CString object:
Copy Code
CString oldString = "This is a test";
CString newString = oldString;
The contents of a CString object are copied when one CString object is assigned to another. Thus, the two strings do not share a reference to the actual characters that make up the string. For more information on using CString objects as values, see the article CString Semantics.
Note
To write your application so that it can be compiled for Unicode or for ANSI, code literal strings using the _T macro. For more information, see the article Unicode and Multibyte Character Set (MBCS) Support.
Accessing Individual Characters in a CString
You can access individual characters within a CString object with the GetAt and SetAt member functions. You can also use the array element, or subscript, operator ( [ ] ) instead of GetAt to get individual characters (this is similar to accessing array elements by index, as in standard C-style strings). Index values for CString characters are zero based.
Concatenating Two CString Objects
To concatenate two CString objects, use the concatenation operators (+ or +=) as follows:
Copy Code
CString s1 = "This "; // Cascading concatenation
s1 += "is a ";
CString s2 = "test";
CString message = s1 + "big " + s2;
// Message contains "This is a big test".
At least one argument to the concatenation operators (+ or +=) must be a CString object, but you can use a constant character string (such as "big") or a char (such as 'x') for the other argument.
Comparing CString Objects
The Compare member function and the == operator for CString are equivalent. Compare, operator==, and CompareNoCase are MBCS and Unicode aware; CompareNoCase is also case insensitive. The Collate member function of CString is locale sensitive and is often slower than Compare. Collate should be used only where it is necessary to abide by the sorting rules as specified by the current locale.
The following table shows the available CString comparison functions and their equivalent Unicode/MBCS-portable functions in the C run-time library:
CString function MBCS function Unicode function
Compare
_mbscmp
wcscmp
CompareNoCase
_mbsicmp
_wcsicmp
Collate
_mbscoll
wcscoll
The CString class overrides the relational operators (<, <=, >=, >, ==, and !=).You can compare two CStrings using these operators, as shown here:
Copy Code
CString s1( "Tom" );
CString s2( "Jerry" );
if( s1 < s2 )
...
See Also
Other Resources
Strings (ATL/MFC)
To make a suggestion or report a bug about Help or another feature of this product, go to the feedback site. --------------------编程问答-------------------- 谢谢 --------------------编程问答-------------------- 老大,不是搜索吧,应该是帮助菜单下面的索引选项吧,你再试试 --------------------编程问答-------------------- .net2003中搜索CHString
补充:.NET技术 , VC.NET