C#编程如何编写“类”方面的程序
原程序功能如下:
  
这个程序功能其实已经完成,
但是现在想学习学习如何引用“类”方面的知识,不知如何

解决方案 »

  1.   

    //读写INI文件功能
    [DllImport("kernel32")]
    public static extern long WritePrivateProfileString(string Section,//指定的节名
           string Key,                                                      //指定的键名
           string Value,
          string FilePath);
    这些都是正常,我想将那些过程,移动到一个新定义的“类”中
    SSSkkin.cs中
    using System;
    using System.IO;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Text;
    using System.Windows.Forms;
    using System.Runtime.InteropServices;  //调用DLL的引用
    using System.Runtime.Serialization.Formatters.Binary;namespace CRMServers
    {
        class FrmSSkin
        {
            #region"基本操作函数"
            //定义[皮肤管理模块]
            //读写INI文件功能        #endregion
        }
    }
      

  2.   

    我说的这个C#中的“类”,就像DELPHI中的单元一样,将一些“过程或者函数体”全
    集中进去,在DELPHI中引用方式是:  单元名称.过程或者函数名(参数)
      

  3.   

    我现在没有实现呀????????
    我在DELPHI中编程实现了,为什么用C#不知如何编程了呀
      

  4.   

    项目中建立一类文件namespace SkinManage
    {
    public class SkinManage()
    {
     //一些方法
    方法一:
    ........
    方法二:
    ......
    }
    }然后调用这个类中的方法:
      

  5.   


    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Runtime.InteropServices;       //添加命名空间
    using System.Text;namespace ConTest3
    {
        class Program
        {
            [DllImport("kernel32")]
            public static extern long WritePrivateProfileString(string Section,//指定的节名
              string Key, //指定的键名
              string Value,
              string FilePath);         //声明函数        static void Main(string[] args)
            {
                try
                {
                    WritePrivateProfileString("Sys", "Happy", "012", "e:\\a.ini");   //调用
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                }
            }
        }
    }LZ会Delphi?
    鄙人也想学学,能介绍些好一点的入门方面的教材么?(我已经有一些PASCAL方面的基础,这方面的可以Pass)
      

  6.   

    你把想试验的功能写到你新定义的“类”SSSkkin.cs中,然后在你需要调用的时候调用类中刚写的函数即可呀。
      

  7.   

    下面我一下DELPHI中的Commonzgxs.pas单元应用
    unit Commonzgxs;
    interface
    uses
      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
      Dialogs, ExtCtrls, Buttons, StdCtrls;
    procedure Fromjz_zhou(MMainFrms:TFORM); //居中窗体
    implementation
    uses Uformain,from_edit, area_edit,fw_edit;
    procedure  Fromjz_zhou(MMainFrms:TFORM); //居中窗体
    begin
       //居中窗体
       with MMainFrms do
         begin
           Align:=alCustom;//alCustom;
           BorderStyle:=bsSingle;
           Position:=poDesktopCenter;
         end;
    end;
      

  8.   

    引用方法,
    在任何一个窗框的引用这个单元:Commonzgxs,就是
    uses Commonzgxs;
    加载方式如下:
    Commonzgxs.Fromjz_zhou(self);
    这个代码可以加载到程序的create事件中即可,程序运行时这个
    窗体就是居中显示的 
      

  9.   

    编写一个公用类就可以了吧,类的本质其实就是一个包含了方法的结构体阿。
    类定义后,在使用的时候是需要声明才可以的,
    而且引用命名空间的方法应该是 using namespace吧?
      

  10.   


    是的大体是就是这个意思,你看一下这个帖子
    http://topic.csdn.net/u/20110820/17/9629137b-047e-46b5-89f9-04ffc1c779df.html