c# 基础

发布时间:2017-1-17 20:56:17 编辑:www.fx114.net 分享查询网我要评论
本篇文章主要介绍了"c# 基础 ",主要涉及到c# 基础 方面的内容,对于c# 基础 感兴趣的同学可以参考一下。

c# 基础

freature of c#
  Assembly Versioning
  Properties and Events
  Delegates and Events Management
  Conditional Compilation
  Simple Multithreading
  LINQ and Lambda Expressions


  There is no package, but nested namespace instead.

namespace outer
namespace inner
    class Demo
        // some code here

value type

  to get exact size of a type of variable, you can use sizeof method.

reference type

  object type

    the object type can be assigned values of any other types,
    value type
    reference type
    or user-defined type

    object obj;
    obj = 100; // this is boxing

  dynamic type
    you can store any type of value in the dynamic data type variable.
    type checking takes place at run-time.

    dynamic <variable_name> = value;
    dynamic d = 20;

    the difference between dynamic type and object type is the time when type checking takes place.
    former's type type checking takes place at run-time.
    later's type type checking takes place at compile time.


    The string type is an alias for the System.String class.
    It is derived from object type.
    There are two forms:
[email protected]

pointer type
  pointer in c# have the same capabilities as the pointers in c or c++.
  we will discuss pointer types as unsafe codes.

lvalue: An expression that is an lvalue may appear as either the left-hand or right-hand side of an assignment.

rvalue: An expression that is an rvalue may appear on the right- but not left-hand side of an assignment.


double[] balance = new double[10];
for (int i = 0; i < 10; i++)
    balance[i] = i;
foreach (double d in balance)
    Console.WriteLine(d + "\n");

structures in c#

struct Books
    public string title;
    public string author;
    public string subject;
    public int book_id;

class versus struct
  *classes are reference types and structs are value types
  structures do not support inheritance
  structures cannot have default constructor

c# has preprocessor directives like in c or c++.

exception handling

以上内容均来自 https://www.tutorialspoint.com/csharp/ 

上一篇:HttpServletRequest cannot be resolved to a type。


关键词: c# 基础