zoukankan      html  css  js  c++  java
  • struct也有方法成员

    using System;
    using System.Collections.Generic;
    using System.Text;

    namespace App1
    {
        
    struct Point
        
    {
            
    public Int32 x, y;
            
    public void Change(Int32 x, Int32 y)
            
    {
                
    this.x = x;
                
    this.y = y;
            }

            
    //public override string ToString()
            
    //{
            
    //    //return base.ToString();
            
    //    return string.Format("{0},{1}", x, y);
            
    //    //return string.Format("{0},{1},{2}", x, y, x);
            
    //}
        }

        
    class Program
        
    {
            
    static void Main(string[] args)
            
    {
                Point p 
    = new Point();
                p.x 
    = p.y = 1;
                Console.WriteLine(p);
                
    //调用p的ToString()方法,若不override---ToString()则输出"App1.Point"
                ///////////////////////////
                Console.Read();
            }

        }

    }

  • 相关阅读:
    LeetCode1049. 最后一块石头的重量 II
    LeetCode416. 分割等和子集
    LeetCode96. 不同的二叉搜索树
    LeetCode343. 整数拆分
    python笔记---内置容器
    Numpy学习笔记(一)
    tensorflow入门代码分析
    神经网络
    回归算法
    机器学习入门笔记
  • 原文地址:https://www.cnblogs.com/shuang/p/1007165.html
Copyright © 2011-2022 走看看