C#编程如何编写“类”方面的程序
原程序功能如下:
这个程序功能其实已经完成,
但是现在想学习学习如何引用“类”方面的知识,不知如何
原程序功能如下:
这个程序功能其实已经完成,
但是现在想学习学习如何引用“类”方面的知识,不知如何
解决方案 »
- 数据库查询的时候报错,“string”必须是具有公共的无参数构造函数的非抽象类型,才能用作泛型类型或方法
- datatable怎么转换为list<string,string>类型
- OpenProcess返回0
- C# socket通信 RGB转换成BMP图片 高手在吗?
- 一个textbox,要求里面一定要输入内容,否则在后面显示一句提醒,怎么做?
- 急求向Word2003文件中插入图片的方法!在线急等!!!!!!!!!!
- (HttpWebRequest)HttpWebRequest.Create("参数Uri")中文问题
- 如何修改主Form的属性?
- C#與DataGrid動態更新問題?請高手和微軟程序員幫助解答!謝謝!(急)
- 模糊概念~~~~~~~~~~~~~~~~
- datagridview多表查询,单表更新
- C# 利用反射反编译DLL的问题
[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
}
}
集中进去,在DELPHI中引用方式是: 单元名称.过程或者函数名(参数)
我在DELPHI中编程实现了,为什么用C#不知如何编程了呀
{
public class SkinManage()
{
//一些方法
方法一:
........
方法二:
......
}
}然后调用这个类中的方法:
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)
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;
在任何一个窗框的引用这个单元:Commonzgxs,就是
uses Commonzgxs;
加载方式如下:
Commonzgxs.Fromjz_zhou(self);
这个代码可以加载到程序的create事件中即可,程序运行时这个
窗体就是居中显示的
类定义后,在使用的时候是需要声明才可以的,
而且引用命名空间的方法应该是 using namespace吧?
是的大体是就是这个意思,你看一下这个帖子
http://topic.csdn.net/u/20110820/17/9629137b-047e-46b5-89f9-04ffc1c779df.html