C#的基础内容

 

定义类的方法html

//要定义对象,必须有其相应的类。类就是描述一些具备相同属性的事物的抽象概念。好比咱们定义一我的员类。以下
class Person
{
  public string name;
  public int age;
  public string sex;
  public Person()
  {
  }
}
//而后定义这个类的对象。

 

 

定义一个数组web

int[] myIntArray;
myIntArray = new int[5];
const int arraySize = 5;
int[] myIntArray = new int[arraySize] { 5, 9, 10, 2, 99 };

动态长度数组sql

 

 

 

 

调用类的方法数据库

 

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Exeplems
{
public class Class1
{
public static void Method()
{
Console.WriteLine("静态的方法能够直接调用!可是很耗资源!");
}
public void Method1()
{
Console.WriteLine("非静态的方法要建立对象来访问!");
}
public void Method2()
{
Method1();//同一类中的方法体能够直接访问静态和非静态的
Method();
}
}
class Program
{
static void Main(string[] args)
{
Class1.Method();//访问静态方法
Class1 obj = new Class1();//建立对象
obj.Method1();//访问非静态方法;必须是public的
}
}
}

 

 

 

数组做为参数的语法

http://kooyee.iteye.com/blog/350017编程

 

数组的嵌套


  int [ ][ ] b = new  int [ 4][ ];  最后的方括号内不写入数字
     b [ 0 ] = new int [ 4];
     b [1 ] = new int [5];              --这几行代码是定义每一行中的元素的个数。
     b [2 ] = new int [2];
     b [ 0][ 1] = 10;  ---赋值。

 

 

C#数组有关知识c#

C# 自定义类型的数组与 Array 类 -- Jakrely 技术文摘
http://www.jakrely.com/csharp-custom-type-array-and-array-class.html数组

 

C#数字格式化编程语言

C#数字格式化 - 飛雲若雪 - 博客园
http://www.cnblogs.com/sydeveloper/archive/2012/08/27/2657824.htmlide

 

 C#中Dictionary的用法_百度经验
http://jingyan.baidu.com/article/9989c7460ab872f648ecfeed.html工具

 

自定义图表

采用了NPlot的第三方库

首先在工具栏导入dll文件,而后在可视化编辑区域拖动加入一个绘图容器,系统会为你建立下面的代码

        private NPlot.Windows.PlotSurface2D plotSurface2D1;
 // 
            // plotSurface2D1
            // 
            this.plotSurface2D1.AutoScaleAutoGeneratedAxes = false;
            this.plotSurface2D1.AutoScaleTitle = false;
            this.plotSurface2D1.BackColor = System.Drawing.SystemColors.ControlLightLight;
            this.plotSurface2D1.DateTimeToolTip = false;
            this.plotSurface2D1.Legend = null;
            this.plotSurface2D1.LegendZOrder = -1;
            this.plotSurface2D1.Location = new System.Drawing.Point(238, 24);
            this.plotSurface2D1.Name = "plotSurface2D1";
            this.plotSurface2D1.RightMenu = null;
            this.plotSurface2D1.ShowCoordinates = true;
            this.plotSurface2D1.Size = new System.Drawing.Size(523, 272);
            this.plotSurface2D1.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.None;
            this.plotSurface2D1.TabIndex = 1;
            this.plotSurface2D1.Text = "plotSurface2D1";
            this.plotSurface2D1.Title = "";
            this.plotSurface2D1.TitleFont = new System.Drawing.Font("Arial", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel);
            this.plotSurface2D1.XAxis1 = null;
            this.plotSurface2D1.XAxis2 = null;
            this.plotSurface2D1.YAxis1 = null;
            this.plotSurface2D1.YAxis2 = null;

 

 介绍使用NPlot的博客

 http://www.cnblogs.com/zeroone/archive/2012/11/04/2753304.html

 http://www.cnblogs.com/sky1991/archive/2012/09/26/2703347.html

须要更新plot的时候,能够用一个属性,每次更改数据源,并进行clear和refresh操做

treeView的使用总结

选择事件中能够得到选中的节点Node

Node中有深度Level和序号Index的属性,能够知道选中的Node的位置。也能够得到其Text属性

 private void treeView1_AfterSelect(object sender, TreeViewEventArgs e)
        {
            Console.WriteLine("abc{0}"+e.Node.Text,sender);
            e.Node.TreeView.ExpandAll();
            Console.WriteLine("get index {0} in level {1}", e.Node.Index,e.Node.Level);
          //  e.Node.TreeView[1]
            //Console.WriteLine("upper level" + e.Node.Parent.Text);//e.Node.PrevVisibleNode.Text
           
        }

 

 

连接数据库

C#读取DBF格式的数据表 - Tsybius2014 - 开源中国社区
http://my.oschina.net/Tsybius2014/blog/278426

 

C# 读取dbf文件中的数据到datatable中 - C#编程语言程序开发技术文章_C#编程 - 红黑联盟
http://www.2cto.com/kf/201311/255404.html

 

本身写的一段连接数据库的代码,是一个button的点击事件,用来测试比较方便

 
  private void button2_Click(object sender, EventArgs e)
        {
            Console.WriteLine("start db read method");
            try
            {
               
                string table = @"E:\test\data.dbf";//dbf文件路径
                string sql = @"select * from " + table;
               OleDbConnection conn = new OleDbConnection("Provider=VFPOLEDB.1;" +
                 "Data Source="+table+";");
                conn.Open();
                OleDbDataAdapter odda = new OleDbDataAdapter(sql, conn);
                DataTable dt = new DataTable();
                odda.Fill(dt);
                Console.WriteLine("data table is {0}", dt.ToString());
                MessageBox.Show("读取完毕,查询结果共计: " + dt.Rows.Count + " 条");
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }

 

microsoft 的资料

OleDbConnection 类 (System.Data.OleDb)
https://msdn.microsoft.com/zh-cn/library/system.data.oledb.oledbconnection(VS.80).aspx

 

输出到系统剪切板,方便调试

           string outString = "";
            for (int i = 0; i < kLineData.CloseData.Count; i++)
            {
                double close = kLineData.CloseData.ElementAt(i);
                outString = outString + System.Environment.NewLine + close;
                Console.WriteLine("number at {0}{1}", i, close);
            }
            outString = outString + System.Environment.NewLine + System.Environment.NewLine + System.Environment.NewLine;
            for (int i = 0; i < MAList.Count; i++)
            {
                outString = outString + System.Environment.NewLine+MAList.ElementAt(i);
            }
            outString = outString + System.Environment.NewLine + System.Environment.NewLine + System.Environment.NewLine;
            for (int i = 0; i < MAList.Count; i++)
            {
                outString = outString + System.Environment.NewLine + upList.ElementAt(i);
            }
            Clipboard.SetText(outString);
相关文章
相关标签/搜索