2012年9月5日 星期三

difference between Casting and Parsing


Casting is changing the type of the variable.
Parsing is 'examining' the string and assigning its logical value to some variable.


http://social.msdn.microsoft.com/forums/en-US/csharpgeneral/thread/57518616-a142-4e89-99c9-e2fa6b01ef6f

What is the difference bewtween x.ToString() and (String) x?
x.ToString() will try to call ToString() on the object x.
(String) x will try to cast x to string, and will fail if x isn't string.


2012年8月30日 星期四

如何在blogger貼上codes

http://mytechmemo.blogspot.com/2012/02/how-to-enable-syntax-highlight-for-code.html

[C/C++] #error用途

強制compiler停止或中斷compile執行, 顯示錯誤訊息
When the preprocessor hits the #error directive, it will report the string as an error message and halt compilation; what exactly the error message looks like depends on the compiler.

The #error macro allows you to make compilation fail and issue a statement that will appear in the list of compilation errors. It is most useful when combined with #if/#elif/#else to fail compilation if some condition is not true.

ex:

#if defined(BUILD_TYPE_NORMAL)
# define DEBUG(x) do {;} while (0) /* paranoid-style null code */
#elif defined(BUILD_TYPE_DEBUG)
# define DEBUG(x) _debug_trace x /* e.g. DEBUG((_debug_trace args)) */
#else
# error "Please specify build type in the Makefile"
#endif



#if defined(BUILD_TYPE_NORMAL)
# define DEBUG(x) do {;} while (0) /* paranoid-style null code */
#elif defined(BUILD_TYPE_DEBUG)
# define DEBUG(x) _debug_trace x /* e.g. DEBUG((_debug_trace args)) */
#else
# error "Please specify build type in the Makefile"
#endif