C#画线控件的应用实例介绍之前我们要明白在C#中没有画线的控件,这里写了一个,大家分享。共有两个控件分别是画横线和画竖线的,关于怎么画斜线有兴趣的可以做一个大家分享。
C#画线控件之横线
using System;
using System.Collections;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Windows.Forms;
namespace Jiashi.WinControls
{
///
/// LineX 画横线控件
///
public class LineX : System.Windows.Forms.UserControl
{
#region 属性定义
private System.Drawing.Color lineColor;
private int lineWidth;
///
/// 线的颜色属性
///
public System.Drawing.Color LineColor
{
set
{
this.lineColor=value; &n ......
asp.net默认的编码是UTF-8
js文件里的编码也是UTF-8
当你要在aspx页面上进行传中文参数时会出现乱码
<-----request.aspx--接收参数页----->
<----response.aspx--传送参数页----->
例一:<a href="request.aspx?str=中国人"></a>
解决办法一:
1.可以和改webconfig的编码 如:
<location path='response.aspx'>
<system.web>
<globalization fileEncoding='gb2312' requestEncoding='gb2312' responseEncoding='gb2312' culture='zh-CN'/>
</system.web>
</location>
注意:你也要把request.aspx页面上的编码也改成同样的,虽然中文乱码解决了,但如果你用到了js文件就会出现乱码
//用这以上方法的话不会改变网站的其它页面上的编码
<location path='request.aspx'>
&n ......
asp.net默认的编码是UTF-8
js文件里的编码也是UTF-8
当你要在aspx页面上进行传中文参数时会出现乱码
<-----request.aspx--接收参数页----->
<----response.aspx--传送参数页----->
例一:<a href="request.aspx?str=中国人"></a>
解决办法一:
1.可以和改webconfig的编码 如:
<location path='response.aspx'>
<system.web>
<globalization fileEncoding='gb2312' requestEncoding='gb2312' responseEncoding='gb2312' culture='zh-CN'/>
</system.web>
</location>
注意:你也要把request.aspx页面上的编码也改成同样的,虽然中文乱码解决了,但如果你用到了js文件就会出现乱码
//用这以上方法的话不会改变网站的其它页面上的编码
<location path='request.aspx'>
&n ......
C#正则表达式匹配字符串的方法如下:
1.使用C#中使用正则表达式System.Text.RegularExpressions命名空间;
2.使用C#中使用正则表达式Matches()方法匹配字符串,格式如下:
MatchCollection Matches = Regex.Matches(Str, Pattern, RegexOptions.IgnoreCase | RegexOptions.ExplicitCapture);
其中Str表示输入字符串,Pattern表示匹配模式,RegexOptions.IgnoreCase表示忽略大小写,RegexOptions.ExplicitCapture表示改变收集匹配方式。
3.匹配结果保存在MatchCollection集合中,可以通过循环遍历结果集取出Match对象的结果。
TestRagular.cs:
using System;
using System.Text.RegularExpressions;
namespace Magci.Test.Strings
{
public class TestRegular
{
public static void WriteMatches(string str, MatchCollection matches)
{
&n ......
和其他语言一样,C#实现文件关联同样需要直接操作注册表,即按规则分别设置文件扩展名,文档类型说明,友好名称,图标,调用方法等键值即可,网上随便查查就可以写出以下的代码。 using Microsoft.Win32; RegistryKey key = Registry.ClassesRoot.OpenSubKey(".jb");
if (key == null)
{
key = Registry.ClassesRoot.CreateSubKey(".jb");
key.SetValue("", "Jeebook.Reader.jb");
key.SetValue("Content Type", "application/jb"); key = Registry.ClassesRoot.CreateSubKey("Jeebook.Reader.jb");
key.SetValue("", "Jeebook Document"); RegistryKey keySub = key.CreateSubKey("DefaultIcon");
keySub.SetValue("", System.Windows.Forms.Application.StartupPath + "Jeebook.ico");
keySub = key.CreateSubKey("shell\\open\\command");
keySub.SetValue("", "\"" + System.Windows.Forms.Applicati ......
手机音乐播发器里有总文件总时间的统计,在酷狗播放器里找了一下没找到。那我想知道这些歌曲的总时间,该怎么办?
其实很简单,稍稍动动手,就能找到答案!
请参考如下步骤:
第一步,保存播放列表,把里面的歌曲保存到一个你喜欢的名字。
第二步,在播放列表上面点右键,到处播放列表到你找的到的地方。
经测试,最新的酷狗2010的播放列表导出后是一个xml文件,里面包含每首歌曲的播放时间,格式如下:
<?xml version="1.0" encoding="utf-8"?>
<List ListName="中文">
<File>
<FileName>[]2002年的第一场雪(英文版)-索菲娅. 格林.wma</FileName>
<FileSize>2350579</FileSize>
<Duration>287507</Duration>
<Hash>03072f9ab3a2a1bdc084b3dbf986d135</Hash>
<Lyric>X:\MP3200912\Lyric\索菲娅 - 2002年的第一场雪 - 03072f9ab3a2a1bdc084b3dbf986d135.krc</Lyric>
</File>
<File>
<FileName>【十大情歌】欢子-心痛2009.mp3</FileName>
<FileSize>8520682</FileSize> ......
c#中基类(父类)中的某方法若想在派生类(子类)中被重写(override),必须将基类中的方法定义为virtual,即虚函数。
若派生类将方法修饰为new,即有意隐藏基类中的方法。
下面看一组代码:
public class Father
{
public void hand()
{
Console.WriteLine("Father.hand");
}
}
public class Son : Father
{
public void hand()
{
Console.WriteLine("Son.hand");
}
static void Main(string[] args)
{
Father son = new Son();
son.hand();
Console.ReadLine();
}
}
输出:Father.hand
警告:“Son.hand()”将隐藏继承的成员“Father.hand()”。若要使当前成员重写该实现,请添加关键字 override。否则,添加关键字 new。
public class Father
{
public void hand()
{
Console.WriteLine("Father.hand");
}
}
public class Son : Father
{
public override void hand()
{
Console.WriteLine("Son.hand");
}
static void Main(string[] ......