1.ref传进去的参数必须进行初始化,out不必int i;SomeMethod( ref i );//语法错误SomeMethod( out i );//通过 2.ref传进去的参数在函数内部可以直接使用,而out不可:public void SomeMethod(ref int i){ int j=i;//通过 //...}public void SomeMethod(out int i){ int j=i;//语法错误 } 3.ref传进去的参数在函数内部可以不被修改,但out必须在离开函
ref和out都是C#中的关键字,所实现的功能也差不多,都是指定一个参数按照引用传递. 对于编译后的程序而言,它们之间没有任何区别,也就是说它们只有语法区别. 总结起来,他们有如下语法区别: .ref传进去的参数必须在调用前初始化,out不必,即: int i; SomeMethod( ref i );//语法错误 SomeMethod( out i );//通过 .ref传进去的参数在函数内部可以直接使用,而out不可: public void SomeMethod(ref int i) {
//commndline: doxygen Doxyfile /**comment /* /** time diff@pre precondition@post endcondition@throw exceptions @param start The start time 参数 @param end The end time @returns timespec a number 返回值 */ timespec diff(timespec start, timespec end) {} 复用D