sbj0707

Web service Remoting ADO.NET Windows server 2003

导航

<2005年8月>
31123456
78910111213
14151617181920
21222324252627
28293031123
45678910

统计

公告

昵称:IT
园龄:6年6个月
粉丝:1
关注:0

搜索

 
 

常用链接

最新随笔

随笔档案(14)

最新评论

阅读排行榜

评论排行榜

推荐排行榜

指针和和一般的数据传递

如下代码为测试代码,有兴趣的话,试下运行结果

using System;

namespace ConsoleTest1
{
    
/// <summary>
    
/// Class1 的摘要说明。
    
/// </summary>

    class Class1
    
{
        
/// <summary>
        
/// 应用程序的主入口点。
        
/// </summary>

        [STAThread]
        
static void Main(string[] args)
        
{
            Student stu
=new Student();
            stu.Name
="Student-1";
            
string str="str-stu-1";
            Change ch
=new Change(stu,str);
            Console.Write(stu.Name
+"\n"+str+"\n");
            Console.ReadLine();
        }

    }

    
class Student
    
{
        
private string name;
        
public string Name
        
{
            
get
            
{
                
return name;
            }

            
set
            
{
                name
=value;
            }

        }

    }

    
class Change
    
{
        
public Change(Student stu,string str)
        
{
            stu.Name
="student-2";
            str
="str-stu-2";
        }

    }

}



运行结果是:
student-2
str-stu-1
为什么不是以下两种
student-2
str-stu-2

student-1
str-stu-1
构造函数的两个参数,一个传的是指针(Student),另一个传的是一般变量(string )

posted on 2005-08-20 09:20 IT 阅读(335) 评论(2) 编辑 收藏

评论

#1楼 2005-08-20 09:29 IT[未注册用户]

我觉得可能是对象类型是传的是指针,而一般基本类型是一般数值传递!!
但是我没有看到过相应的文章,还有在C# string也是个对象,不知道里面的机制了,呵呵!!!!!
 回复 引用   

#2楼 2005-08-20 15:30 dudu      

请将文章放在正确的网站分类!!  回复 引用 查看