PIXNET Logo登入

遊戲人生 人生遊戲

跳到主文

如果工作是玩樂就太好了

部落格全站分類:攝影寫真

  • 相簿
  • 部落格
  • 留言
  • 名片
  • 8月 24 週二 201021:17
  • C# 委派和事件

C# 委派和事件
  
(繼續閱讀...)
文章標籤

createps 發表在 痞客邦 留言(0) 人氣(468)

  • 個人分類:C#
▲top
  • 8月 23 週一 201015:30
  • C# 取亂數 record

同步發表於Google Blogger
c#:
Random 亂數 = new Random();//亂數種子
int i = 亂數.Next(0, 100);//回傳0-99的亂數
如果用for 或其它回圈抓亂數,一定要把 Random 亂數 = new Random();//亂數種子 放在回圈外面, VB也一樣。
(繼續閱讀...)
文章標籤

createps 發表在 痞客邦 留言(0) 人氣(37,169)

  • 個人分類:C#
▲top
  • 8月 22 週日 201023:18
  • VB和C# 字串比較 record





VB


pecial character constants (all also accessible from ControlChars class)
vbCrLf, vbCr, vbLf, vbNewLine 
vbNullString 
vbTab 
vbBack 
vbFormFeed 
vbVerticalTab
""


' String concatenation (use & or +) 
Dim school As String = "Harding" & vbTab
school = school & "University" ' school is "Harding (tab) University"


' Chars
Dim letter As Char = school.Chars(0)   ' letter is H 
letter = "Z"c                                         ' letter is Z 
letter = Convert.ToChar(65)                ' letter is A 
letter = Chr(65)                                 ' same thing 
Dim word() As Char = school.ToCharArray() ' word holds Harding


' No string literal operator 
Dim msg As String = "File is c:\temp\x.dat" 


' String comparison
Dim mascot As String = "Bisons"
If (mascot = "Bisons") Then   ' true
If (mascot.Equals("Bisons")) Then   ' true
If (mascot.ToUpper().Equals("BISONS")) Then  ' true
If (mascot.CompareTo("Bisons") = 0) Then   ' true


' String matching with Like - Regex is more powerful
If ("John 3:16" Like "Jo[Hh]? #:*") Then   'true


' Substring
s = mascot.Substring(2, 3)) ' s is "son"


' Replacement
s = mascot.Replace("sons", "nomial")) ' s is "Binomial"


' Split
Dim names As String = "Michael,Dwight,Jim,Pam"
Dim parts() As String = names.Split(",".ToCharArray())   ' One name in each slot


' Date to string
Dim dt As New DateTime(1973, 10, 12)
Dim s As String = "My birthday: " & dt.ToString("MMM dd, yyyy")   ' Oct 12, 1973


' Integer to String
Dim x As Integer = 2
Dim y As String = x.ToString()     ' y is "2"


' String to Integer
Dim x As Integer = Convert.ToInt32("-5")     ' x is -5




' Mutable string 
Dim buffer As New System.Text.StringBuilder("two ")
buffer.Append("three ")
buffer.Insert(0, "one ")
buffer.Replace("two", "TWO")
Console.WriteLine(buffer)         ' Prints "one TWO three"




C#


Escape sequences
\r    // carriage-return
\n    // line-feed
\t    // tab
\\    // backslash
\"    // quote 


// String concatenation
string school = "Harding\t"; 
school = school + "University";   // school is "Harding (tab) University"


// Chars
char letter = school[0];            // letter is H 
letter = 'Z';                               // letter is Z 
letter = Convert.ToChar(65);     // letter is A 
letter = (char)65;                    // same thing 
char[] word = school.ToCharArray();   // word holds Harding


// String literal 
string msg = @"File is c:\temp\x.dat"; 
// same as 
string msg = "File is c:\\temp\\x.dat"; 


// String comparison
string mascot = "Bisons"; 
if (mascot == "Bisons")    // true
if (mascot.Equals("Bisons"))   // true
if (mascot.ToUpper().Equals("BISONS"))   // true
if (mascot.CompareTo("Bisons") == 0)    // true


// String matching - No Like equivalent, use Regex



// Substring
s = mascot.Substring(2, 3))     // s is "son"


// Replacement
s = mascot.Replace("sons", "nomial"))     // s is "Binomial"


// Split
string names = "Michael,Dwight,Jim,Pam";
string[] parts = names.Split(",".ToCharArray());   // One name in each slot


// Date to string
DateTime dt = new DateTime(1973, 10, 12);
string s = dt.ToString("MMM dd, yyyy");     // Oct 12, 1973


// int to string
int x = 2;
string y = x.ToString();     // y is "2"


// string to int
int x = Convert.ToInt32("-5");     // x is -5

 


// Mutable string 
System.Text.StringBuilder buffer = new System.Text.StringBuilder("two "); 
buffer.Append("three "); 
buffer.Insert(0, "one "); 
buffer.Replace("two", "TWO"); 
Console.WriteLine(buffer);     // Prints "one TWO three"





(繼續閱讀...)
文章標籤

createps 發表在 痞客邦 留言(1) 人氣(1,265)

  • 個人分類:C#
▲top
  • 8月 22 週日 201020:45
  • C# 大樂透對獎程式

Noname
更新:2014/01/24
新的下載地址:
https://dl.dropboxusercontent.com/u/67874009/loto.zip
功能更新
(繼續閱讀...)
文章標籤

createps 發表在 痞客邦 留言(17) 人氣(11,581)

  • 個人分類:C#
▲top
  • 8月 22 週日 201009:54
  • C# function 參數參照 record

// Pass by value (in, default), reference (in/out), and reference (out)
void TestFunc(int x, ref int y, out int z) {
  x++;  
  y++;
  z = 5;
}
(繼續閱讀...)
文章標籤

createps 發表在 痞客邦 留言(0) 人氣(468)

  • 個人分類:C#
▲top
  • 8月 22 週日 201009:50
  • C# 分隔分符串 record

class TestStringSplit
{
static void Main()
{
char[] delimiterChars = { ' ', ',', '.', ':', '\t' };

string text = "one\ttwo three:four,five six seven";
System.Console.WriteLine("Original text: '{0}'", text);

string[] words = text.Split(delimiterChars);
System.Console.WriteLine("{0} words in text:", words.Length);

foreach (string s in words)
{
System.Console.WriteLine(s);
}
}
}
(繼續閱讀...)
文章標籤

createps 發表在 痞客邦 留言(0) 人氣(67)

  • 個人分類:C#
▲top
  • 8月 22 週日 201000:12
  • C# 字串格式 record

字串格式:
double[] numbers= {1054.32179, -195489100.8377, 1.0437E21, 
                   -1.0573e-05};
string[] specifiers = { "C", "E", "e", "F", "G", "N", "P", 
                        "R", "#,000.000", "0.###E-000"};
foreach (double number in numbers)
{
   Console.WriteLine("Formatting of {0}:", number);
   foreach (string specifier in specifiers)
      Console.WriteLine("   {0,5}: {1}", 
                        specifier, number.ToString(specifier));
   Console.WriteLine();
}
// The example displays the following output to the console:
//       Formatting of 1054.32179:
//              C: $1,054.32
//              E: 1.054322E+003
//              e: 1.054322e+003
//              F: 1054.32
//              G: 1054.32179
//              N: 1,054.32
//              P: 105,432.18 %
//              R: 1054.32179
//          #,000.000: 1,054.322
//          0.###E-000: 1.054E003
//       
//       Formatting of -195489100.8377:
//              C: ($195,489,100.84)
//              E: -1.954891E+008
//              e: -1.954891e+008
//              F: -195489100.84
//              G: -195489100.8377
//              N: -195,489,100.84
//              P: -19,548,910,083.77 %
//              R: -195489100.8377
//          #,000.000: -195,489,100.838
//          0.###E-000: -1.955E008
//       
//       Formatting of 1.0437E+21:
//              C: $1,043,700,000,000,000,000,000.00
//              E: 1.043700E+021
//              e: 1.043700e+021
//              F: 1043700000000000000000.00
//              G: 1.0437E+21
//              N: 1,043,700,000,000,000,000,000.00
//              P: 104,370,000,000,000,000,000,000.00 %
//              R: 1.0437E+21
//          #,000.000: 1,043,700,000,000,000,000,000.000
//          0.###E-000: 1.044E021
//       
//       Formatting of -1.0573E-05:
//              C: $0.00
//              E: -1.057300E-005
//              e: -1.057300e-005
//              F: 0.00
//              G: -1.0573E-05
//              N: 0.00
//              P: 0.00 %
//              R: -1.0573E-05
//          #,000.000: 000.000
//          0.###E-000: -1.057E-005
 
  
  
    //2007-4-24   
  
    this.TextBox7.Text = System.DateTime.Now.ToString("d");   
  
  
  
    //2007年4月24日 16:30:15   
  
    this.TextBox8.Text = System.DateTime.Now.ToString("F");   
  
    //2007年4月24日 16:30   
  
    this.TextBox9.Text = System.DateTime.Now.ToString("f");   
  
  
  
    //2007-4-24 16:30:15   
  
    this.TextBox10.Text = System.DateTime.Now.ToString("G");   
  
    //2007-4-24 16:30   
  
    this.TextBox11.Text = System.DateTime.Now.ToString("g");   
  
  
  
    //16:30:15   
  
    this.TextBox12.Text = System.DateTime.Now.ToString("T");   
  
    //16:30   
  
    this.TextBox13.Text = System.DateTime.Now.ToString("t");   
  
  
  
    //2007年4月24日 8:30:15   
  
    this.TextBox14.Text = System.DateTime.Now.ToString("U");   
  
    //2007-04-24 16:30:15Z   
  
    this.TextBox15.Text = System.DateTime.Now.ToString("u");   
  
  
  
    //4月24日   
  
    this.TextBox16.Text = System.DateTime.Now.ToString("m");   
  
    this.TextBox16.Text = System.DateTime.Now.ToString("M");   
  
    //Tue, 24 Apr 2007 16:30:15 GMT   
  
    this.TextBox17.Text = System.DateTime.Now.ToString("r");   
  
    this.TextBox17.Text = System.DateTime.Now.ToString("R");   
  
    //2007年4月   
  
    this.TextBox19.Text = System.DateTime.Now.ToString("y");   
  
    this.TextBox19.Text = System.DateTime.Now.ToString("Y");   
  
    //2007-04-24T15:52:19.1562500+08:00   
  
    this.TextBox20.Text = System.DateTime.Now.ToString("o");   
  
    this.TextBox20.Text = System.DateTime.Now.ToString("O");   
  
    //2007-04-24T16:30:15   
  
    this.TextBox18.Text = System.DateTime.Now.ToString("s");   
  
    //2007-04-24 15:52:19   
  
    this.TextBox21.Text = System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss:ffff");   
  
    //2007年04月24 15时56分48秒   
  
    this.TextBox22.Text = System.DateTime.Now.ToString("yyyy年MM月dd HH时mm分ss秒");   
  
  
  
  
  
    //星期二, 四月 24 2007   
  
    this.TextBox1.Text = System.DateTime.Now.ToString("dddd, MMMM dd yyyy");   
  
    //二, 四月 24 '07   
  
    this.TextBox2.Text = System.DateTime.Now.ToString("ddd, MMM d \"'\"yy");   
  
    //星期二, 四月 24   
  
    this.TextBox3.Text = System.DateTime.Now.ToString("dddd, MMMM dd");   
  
    //4-07   
  
    this.TextBox4.Text = System.DateTime.Now.ToString("M/yy");   
  
    //24-04-07   
  
    this.TextBox5.Text = System.DateTime.Now.ToString("dd-MM-yy");   
  
  
  
字符型转换 转为字符串   
  
    12345.ToString("n"); //生成 12,345.00   
  
    12345.ToString("C"); //生成 ¥12,345.00   
  
    12345.ToString("e"); //生成 1.234500e+004   
  
    12345.ToString("f4"); //生成 12345.0000   
  
    12345.ToString("x"); //生成 3039 (16进制)   
  
    12345.ToString("p"); //生成 1,234,500.00%
(繼續閱讀...)
文章標籤

createps 發表在 痞客邦 留言(0) 人氣(275)

  • 個人分類:C#
▲top
  • 8月 21 週六 201022:46
  • C# 使用VB的Collection集合 record


1.First, add a reference to Microsoft.VisualBasic to your project. You can find the Microsoft.VisualBasic in the list on the .Net tab when you open the Add reference dialog.
2.At the top of your code, where the using directives are, you add the following line of code:
using Microsoft.VisualBasic;
3.Now you can use the Collections object.
(繼續閱讀...)
文章標籤

createps 發表在 痞客邦 留言(0) 人氣(267)

  • 個人分類:C#
▲top
  • 8月 21 週六 201021:37
  • C# 隨心所欲產生圖案 record


隨心所欲產生圖案
Written by: Christoph Wille
Translated by: Jacky Chen
First published: 2000/07/28
要是沒有外部的元件支援,有一些東西是 ASP 無法辦到的,也就是動態產生圖案 - 不管是圖表、橫幅廣告、或是簡單的圖形計數器。幸運的是,這在 ASP.NET 中已經改變了 - 使用內建的方法,圖案可以動態產生以及能夠用最大限度的組態設定能力傳送到 client 端,且很容易辦到。
使用本文章的原始程式碼必須在 Webserver 安裝 Microsoft .NET Framework SDK。同時我也假設讀者對 C# 程式有一定程度的認識。
產生圖案
在還沒感受到 ASP.NET 龐大壓力下,我做了一個較乏味簡單的指令行程式,然後使用這個原始程式碼作為我們 ASP.NET script 的基礎。所不同的是這個指令行會將圖案儲存為一檔案,而 ASP.NET script 將他送到 client 端。
現在,我們的範例程式做了什麼?就像一般常見的,一開始我們使用一般喜歡用的 "Hello World" 程式,文字會輸出成一圖案檔,然後圖案會依據目前所選定的字型以及字型大小,產生同樣大小的 "Hello World" 文字(因此,要產生特大的圖像就無法計算)
下面的 Script (pagecounter.cs) 是典型簡單的指令行程式: 忽略包裹在周圍的 class , 只有函式 Main執行時會被呼叫,這也就是我們產生圖案所在的程式。
using System;
using System.IO;
using System.Drawing;
using System.Drawing.Imaging;
public class CTestBitmapFunctionality
{
 public static void Main()
 {
  Bitmap newBitmap = null;
  Graphics g = null ;
  try 
  {
   Font fontCounter = new Font("Lucida Sans Unicode", 12);
   // calculate size of the string.
   newBitmap = new Bitmap(1,1,PixelFormat.Format32bppARGB);
   g = Graphics.FromImage(newBitmap);
   SizeF stringSize = g.MeasureString("Hello World", fontCounter);
   int nWidth = (int)stringSize.Width;
   int nHeight = (int)stringSize.Height;
   g.Dispose();
   newBitmap.Dispose();
   
   newBitmap = new Bitmap(nWidth,nHeight,PixelFormat.Format32bppARGB);
   g = Graphics.FromImage(newBitmap);
   g.FillRectangle(new SolidBrush(Color.White), 
       new Rectangle(0,0,nWidth,nHeight));
   g.DrawString("Hello World", fontCounter, 
        new SolidBrush(Color.Black), 0, 0);
 
   newBitmap.Save("c:\\test.png", ImageFormat.PNG);
  } 
  catch (Exception e)
  {
   Console.WriteLine(e.ToString());
  }
  finally 
  {
   if (null != g) g.Dispose();
   if (null != newBitmap) newBitmap.Dispose();
  }
 }
}
(繼續閱讀...)
文章標籤

createps 發表在 痞客邦 留言(0) 人氣(2,828)

  • 個人分類:C#
▲top
  • 8月 21 週六 201011:00
  • C# 陣列宣告 record


C# 陣列宣告
C#和C語言的陣列宣告很不一樣,所以特別拿出來介紹。
static void Main()
{
// Declare a single-dimensional array
int[] array1 = new int[5];
// Declare and set array element values
int[] array2 = new int[] { 1, 3, 5, 7, 9 };
// Alternative syntax
int[] array3 = { 1, 2, 3, 4, 5, 6 };
// Declare a two dimensional array
int[,] multiDimensionalArray1 = new int[2, 3];
// Declare and set array element values
int[,] multiDimensionalArray2 = { { 1, 2, 3 }, { 4, 5, 6 } };
// Declare a jagged array
int[][] jaggedArray = new int[6][];
// Set the values of the first array in the jagged array structure
jaggedArray[0] = new int[4] { 1, 2, 3, 4 };
}
(繼續閱讀...)
文章標籤

createps 發表在 痞客邦 留言(0) 人氣(2,875)

  • 個人分類:C#
▲top
«1...17181920»

最新文章

  • 中華電信、無線IP分享器和網路交換器如何連接
  • 把大容量的照片縮小, 圖片壓縮
  • 如何在Facebook建立應用程式
  • C# 網卡實體位置 record
  • C# 透過 WMI 取得硬碟序號 ( 物理 / 邏輯磁碟) record
  • C# ComboBox的MaxDropDownItems 沒反應 record
  • XNA 3D動畫,模型變型 record
  • C# 讀取大的圖檔時發生記憶體不足的問題。(轉載) record
  • C# 取得檔案類型 record
  • C# 是否為JPG檔案 record

文章精選

個人資訊

createps
暱稱:
createps
分類:
攝影寫真
好友:
累積中
地區:

熱門文章

  • (16,198)C# Dictionary用法 record
  • (15,018)C# lock record
  • (11,581)C# 大樂透對獎程式
  • (8,748)C# 取得目前時間:年 月 日 record
  • (7,017)C# 讀檔寫檔 record
  • (5,849)C# ListView record
  • (1,770)C# 父子視窗應用 record
  • (1,287)Apple iphone4 (iOS 4.1版) JB 之後的心得 from iTunes 10
  • (1,265)VB和C# 字串比較 record
  • (252)用1-52數字表示撲克牌的每一張牌 record

文章分類

  • 網路硬體 (1)
  • Facebook (1)
  • 懷孕 (1)
  • 程式使用 (1)
  • XNA 4.0 (2)
  • DirectX (15)
  • Corona (29)
  • Lua (2)
  • Unity3D (3)
  • OS (2)
  • 輸入法 (1)
  • 大易 (1)
  • VB.NET (2)
  • Shader (1)
  • 技巧 (2)
  • 笑話 (1)
  • 創業 (4)
  • FTP (2)
  • SQL (1)
  • 歌曲 (4)
  • 物理 (1)
  • Apple (3)
  • Game (1)
  • Game (1)
  • C++ (4)
  • XNA (12)
  • GRD3 (1)
  • 喜歡的歌 (1)
  • C# (87)
  • 國外旅遊 (2)
  • 未分類文章 (1)

最新留言

  • [22/06/15] 訪客 於文章「中華電信、無線IP分享器和網路交換器如何...」留言:
    你好 為什麼我根據你的接法使用後 Wi-fi能使用 但是在交...
  • [22/04/15] 訪客 於文章「C# 大樂透對獎程式...」留言:
    回饋您這方面資訊,我是從 PTT搜尋引擎的排名,看...
  • [18/05/31] dwchen52 於文章「C# 讀取大的圖檔時發生記憶體不足的問題...」留言:
    謝謝你的建議,讓解決我的問題....
  • [18/05/11] y257574 於文章「把大容量的照片縮小, 圖片壓縮 ...」留言:
    x5PKD9ozVGQUIn5R1奢侈品仿牌,保固說到做到,...
  • [15/09/01] 菁 於文章「iphone 在首頁新增資料夾...」留言:
    謝謝您!...
  • [15/08/16] 訪客 於文章「C# 大樂透對獎程式...」留言:
    你好,我剛剛做出來了,原來我犯了一個很不該犯的錯誤… 因為...
  • [15/08/16] 訪客 於文章「C# 大樂透對獎程式...」留言:
    是的,我也是這麼想的,用f11看了幾次程式跑的流程… 很抱...
  • [15/08/15] 訪客 於文章「C# 大樂透對獎程式...」留言:
    你好,目前我在學寫程式 老師上課的範例 在中了幾號碼那邊...
  • [15/03/08] 俴 誏 ? 闚 於文章「把大容量的照片縮小, 圖片壓縮 ...」留言:
    比們地要點重他一並開物我不工問得到時多點要為上 氣~質...
  • [15/02/25] 訪客 於文章「C# 大樂透對獎程式...」留言:
    大大可以私密教我寫兌獎嗎?我剩下兌獎了 其他都好了...

文章搜尋

誰來我家

參觀人氣

  • 本日人氣:
  • 累積人氣: