c# 基础

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

c# 基础

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

namespace

  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.

  string

    The string type is an alias for the System.String class.
    It is derived from object type.
    There are two forms:
      quoted
      @quoted

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.

array

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
  try
  catch
  finally
  throw

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


上一篇:HttpServletRequest cannot be resolved to a type。
下一篇:页面布局

相关文章

关键词: c# 基础

相关评论

本站评论功能暂时取消,后续此功能例行通知。

一、不得利用本站危害国家安全、泄露国家秘密,不得侵犯国家社会集体的和公民的合法权益,不得利用本站制作、复制和传播不法有害信息!

二、互相尊重,对自己的言论和行为负责。

好贷网好贷款