zoukankan      html  css  js  c++  java
  • 向string,int,类对象等中扩展方法

     1 using System;
     2 using System.Collections.Generic;
     3 using System.Linq;
     4 using System.Text;
     5 
     6 namespace ConsoleApplication1
     7 {
     8     class Program
     9     {
    10         static void Main(string[] args)
    11         {
    12             string s = "sss";
    13             s.Res();
    14             /**************************/
    15             student stu = new student("11013141","二货");
    16             stu.Say();
    17             stu.sayhello();
    18         }
    19     }
    20     /// <summary>
    21     /// 扩展方法写在一个静态类中
    22     /// </summary>
    23     public static class Test
    24     {
    25         public static void Res(this string s)
    26         {
    27             Console.WriteLine(s);
    28         }
    29         public static void sayhello(this student s)
    30         {
    31             Console.WriteLine(" 编号:" + s.No+";姓名:" + s.Name);
    32         }
    33     }
    34     public class student
    35     {
    36         //public student() { }
    37         public student(string no,string name)
    38         {
    39             this.No = no;
    40             this.Name = name;
    41         }
    42         private string no;
    43 
    44         public string No
    45         {
    46             get { return no; }
    47             set { no = value; }
    48         }
    49         private string name;
    50 
    51         public string Name
    52         {
    53             get { return name; }
    54             set { name = value; }
    55         }
    56         public void Say()
    57         {
    58             Console.WriteLine("姓名:"+Name+"; 编号:"+No);
    59         }
    60     }
    61 }
  • 相关阅读:
    spark性能调优 数据倾斜 内存不足 oom解决办法
    python2的中文编码
    spark UDF函数
    spark cache table
    spark 创建稀疏向量和矩阵
    mysql 分组排序
    给pyspark 设置新的环境
    CF662C Binary Table
    bzoj 4310 跳蚤
    3.29省选模拟赛 除法与取模 dp+组合计数
  • 原文地址:https://www.cnblogs.com/minotmin/p/3105370.html
Copyright © 2011-2022 走看看