C# TCP 服务端(PC)与客户端(PPC) 简单代码
服务器端代码
控件:btnStart_Click,btnSend_Click,label4,textBox1
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Collections;
using System.Threading;
using System.Net.Sockets;
using System.Net;
namespace MobileServer
{
public partial class FrmEasy : Form
{
//变量
private ThreadStart start;
private Thread listenThread,client_th;
static private bool m_bListening = false;
//static private System.Net.IPAddress MyIP = System.Net.IPAddress.Parse("192.168.1.3");
//获得当前服务端的IP 地址
static private System.Net.IPAddress MyIP = Dns.Resolve(Dns.GetHostName()).AddressList[0];
static private TcpListener listener = new TcpListener(MyIP, 5567);
private String msg;
ArrayList clientArray = new ArrayList();
public FrmEasy()
{
InitializeComponent();
Control.CheckForIllegalCrossThreadCalls = false;
start = new ThreadStart(startListen);
listenThread = new Thread(start);
}
private void btnStart_Click(objec
相关文档:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.SqlClient;
using System.Data;
namespace ConsoleApplication4
{
class Program
{
static void Main(string[] args)
{
//sqlserver身份验证
//s ......
参考《ASP.NET与SQL一起打包部署安装》
,这篇文章是针对VB.NET与SQL 一起打包的,但是我使用的是C#,当然只要修改一下主要安装类库就行了!C#的类库代码如下:DBCustomAction.cs
using System;
using System.Collections;
using System.Data.SqlClient;
using System.ComponentModel;
using System.Configuration.Inst ......
一.类与结构的示例比较:
结构示例:
public struct Person
{
string Name;
int height;
int weight
public bool overWeight()
{
//implement something
}
}
类示例:
public class TestTime
{
int hours;
int minutes;
int seconds;
public void passtime()
{
//implementation ......
先声明,我不是这方面的专家,只是干软件四个月不知天有多高地有多硬的小孩子
首先,类型转换是有一定开销的
我试过这样的代码:这是一个控制台应用程序的Program类的代码
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace 类型转换的开销
{
class Program
......
1. new有几种用法
3种 实例对象 方法隐藏
2.如何把一个array复制到arrayList里
foreach( object o in array )arrayList.Add(o);
3.datagrid.datasouse可以连接什么数据源
数据集DataSet
4.概述反射和序列化
动态获得 ......