TITLE-TEXT

SHORT DESCRIPTION HERE , ...
title

TITLE-TEXT

SHORT DESCRIPTION HERE , ...
title
ewefr

test

張貼者: Tony

public static string getCASEDPFSEL(string IPROFILE_ID)
{
IDataReader FSEL = selCASEDPFSEL(IPROFILE_ID);
string lsFieldStr = string.Empty;
while (FSEL.Read())
{
lsFieldStr = lsFieldStr + Convert.ToString(FSEL["COLNAME_TX"]) + ",";
}
FSEL.Close();

return lsFieldStr;
}

SyntaxHighlighter使用方法

張貼者: Tony

先找到<b:skin>標籤,在此標籤前加入以下代碼。

<!-- SyntaxHighlighter  3.0.83-->
<link href='http://alexgorbatchev.com/pub/sh/current/styles/shCore.css' rel='stylesheet' type='text/css'/>
<link href='http://alexgorbatchev.com/pub/sh/current/styles/shThemeDefault.css' rel='stylesheet' type='text/css'/>
<script src='http://alexgorbatchev.com/pub/sh/current/scripts/shCore.js' type='text/javascript'/>
<script src='http://alexgorbatchev.com/pub/sh/current/scripts/shAutoloader.js' type='text/javascript'/>

再找到</body>標籤,在標籤前加入以下代碼。

<!-- SyntaxHighlighter  3.0.83-->
<script type='text/javascript'>
SyntaxHighlighter.autoloader(
  'applescript            http://alexgorbatchev.com/pub/sh/current/scripts/shBrushAppleScript.js',
  'actionscript3 as3      http://alexgorbatchev.com/pub/sh/current/scripts/shBrushAS3.js',
  'bash shell             http://alexgorbatchev.com/pub/sh/current/scripts/shBrushBash.js',
  'coldfusion cf          http://alexgorbatchev.com/pub/sh/current/scripts/shBrushColdFusion.js',
  'cpp c                  http://alexgorbatchev.com/pub/sh/current/scripts/shBrushCpp.js',
  'c# c-sharp csharp      http://alexgorbatchev.com/pub/sh/current/scripts/shBrushCSharp.js',
  'css                    http://alexgorbatchev.com/pub/sh/current/scripts/shBrushCss.js',
  'delphi pascal          http://alexgorbatchev.com/pub/sh/current/scripts/shBrushDelphi.js',
  'diff patch pas         http://alexgorbatchev.com/pub/sh/current/scripts/shBrushDiff.js',
  'erl erlang             http://alexgorbatchev.com/pub/sh/current/scripts/shBrushErlang.js',
  'groovy                 http://alexgorbatchev.com/pub/sh/current/scripts/shBrushGroovy.js',
  'java                   http://alexgorbatchev.com/pub/sh/current/scripts/shBrushJava.js',
  'jfx javafx             http://alexgorbatchev.com/pub/sh/current/scripts/shBrushJavaFX.js',
  'js jscript javascript  http://alexgorbatchev.com/pub/sh/current/scripts/shBrushJScript.js',
  'perl pl                http://alexgorbatchev.com/pub/sh/current/scripts/shBrushPerl.js',
  'php                    http://alexgorbatchev.com/pub/sh/current/scripts/shBrushPhp.js',
  'text plain             http://alexgorbatchev.com/pub/sh/current/scripts/shBrushPlain.js',
  'py python              http://alexgorbatchev.com/pub/sh/current/scripts/shBrushPython.js',
  'ruby rails ror rb      http://alexgorbatchev.com/pub/sh/current/scripts/shBrushRuby.js',
  'sass scss              http://alexgorbatchev.com/pub/sh/current/scripts/shBrushSass.js',
  'scala                  http://alexgorbatchev.com/pub/sh/current/scripts/shBrushScala.js',
  'sql                    http://alexgorbatchev.com/pub/sh/current/scripts/shBrushSql.js',
  'vb vbnet               http://alexgorbatchev.com/pub/sh/current/scripts/shBrushVb.js',
  'xml xhtml xslt html    http://alexgorbatchev.com/pub/sh/current/scripts/shBrushXml.js'
);
SyntaxHighlighter.config.bloggerMode = true;
SyntaxHighlighter.all()
</script>




<pre class="brush: 語言名稱" title="標題名稱">
    程式碼打在這裡
</pre>


C#-Array.Exists(arrays,match) match泛行的寫法

張貼者: Tony

方法一

string name = "Jack6";

        protected void Page_Load(object sender, EventArgs e)
        {
           
            string[] names = new string[] {"Jack","Jucy","Michael","Antony" };

            bool IsExist = Array.Exists(names, match);

            Response.Write(IsExist.ToString());
        }

        public  bool match(string nameArray) {
            return nameArray == name;
        }

方法二
string name = "Jack6";

        protected void Page_Load(object sender, EventArgs e)
        {
           
            string[] names = new string[] {"Jack","Jucy","Michael","Antony" };

            bool IsExist = Array.Exists(names,
                                                                 (string value)=>
                                                                  {
                                                                        return value == name;
                                                                   }
                                                       );

            Response.Write(IsExist.ToString());
        }

方法三
string name = "Jack6";

        protected void Page_Load(object sender, EventArgs e)
        {
           
            string[] names = new string[] {"Jack","Jucy","Michael","Antony" };

            bool IsExist = Array.Exists(names, x=>x.Equals(name));
            Response.Write(IsExist.ToString());
        }

C#-Guid格式

張貼者: Tony

var guid = Guid.NewGuid();

// 10244798-9a34-4245-b1ef-9143f9b1e68a
Console.WriteLine(guid.ToString("D"));

// 102447989a344245b1ef9143f9b1e68a
Console.WriteLine(guid.ToString("N"));

// {10244798-9a34-4245-b1ef-9143f9b1e68a}
Console.WriteLine(guid.ToString("B"));

// (10244798-9a34-4245-b1ef-9143f9b1e68a)
Console.WriteLine(guid.ToString("P"));

C#-字串操作

張貼者: Tony

字串陣列宣告

string[] array = new string[] { "A""B""C""D""E" }; 
string[] array = "A""B""C""D""E" }; 

字串轉字串陣列、字串陣列轉字串

string[] d = "1,2,3".Split(',');
string f = String.Join(",", d);

字串陣列轉List
List<string> listStr = new List<string>(array);

字串陣列委派
var days = Array.FindAll(array,match);

public static bool match(string str)
{
if (str == "A")
return true;
if (str == "B")
return true;

return false;
}  

List委派
var days = listStr.FindAll(match);

public static bool match(string str)
{
if (str == "A")
return true;
if (str == "B")
return true;

return false;
} 

C#-delegate調用範例

張貼者: Tony

委派調用1
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleAP
{
    class MulticastTester
    {
         delegate void Greeting();


        public static void main()
        {

            Greeting SayHello = new Greeting(SayHelloGo);
            Greeting SayHi = new Greeting(SayHiGo);
            Greeting SayHelloAndHi = SayHello + SayHi;
            Greeting SayBye = new Greeting(SayByeGo);

            SayHi();
            SayHello();
            SayHelloAndHi();

            SayHelloAndHi += SayBye;
            SayHelloAndHi += SayHello;
            SayHelloAndHi += SayHello;
            SayHelloAndHi();
            Console.WriteLine("-----------------------------");
            SayHelloAndHi -= SayHello;
            SayHelloAndHi -= SayHello;
            SayHelloAndHi();


            Console.ReadKey();
        }


        public static void SayHelloGo() {
            Console.WriteLine("Hello!");
        }

        public static void SayHiGo() {
            Console.WriteLine("Hi!");
        }

        public static void SayByeGo() {
            Console.WriteLine("Bye!");
        }

    }
}

委派調用2
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleAP
{
    class delegateTest
    {
        public delegate int mydelegate(int i,int j);

        public static void Main()
        {
            mydelegate AddGo = new mydelegate(Add);
            Console.WriteLine("9+1=");
            Console.WriteLine(AddGo(9,1).ToString());

            mydelegate SubGo = new mydelegate(Sub);
            Console.WriteLine("9-1=");
            Console.WriteLine(SubGo(9, 1).ToString());


            Console.ReadKey();
        }

        public static int Add(int i,int j){
            return i + j;
        }

        public static int Sub(int i, int j) {
            return i - j;
        }

    }
}

C#語法 Word轉Pdf、合併Word、下載MS檔案

張貼者: Tony

這個要先加入Microsoft.Office.Interop.Word參考
using Word = Microsoft.Office.Interop.Word;
using System.Reflection;//這個記得參考


Word轉Pdf
public static bool ConvertWordtoPdf(object WoldFilePath, object PdfFilePath)
{
// 在此处放置用户代码以初始化页面
object Missing = Type.Missing;
Word.Application WordApp = new Microsoft.Office.Interop.Word.Application();
//必须设置为不可见
WordApp.Visible = false;
try
{
//Document doc = new Document(WoldFilePath.ToString());
//doc.Save(PdfFilePath.ToString());
//创建以strTemp为模板的文档
//object oTemplate = Server.MapPath(strTemp);

Word.Document WordDoc = WordApp.Documents.Add(ref WoldFilePath, ref Missing, ref Missing, ref Missing);
WordDoc.Activate();

//对标签"Title"进行填充
//string strBM = "Title";
//object objBM = strBM;
//if (WordApp.ActiveDocument.Bookmarks.Exists(strBM) == true)
//{
// WordApp.ActiveDocument.Bookmarks.get_Item(ref objBM).Select();
// WordApp.Selection.TypeText("公文標題");
//}

object FileFormat = Microsoft.Office.Interop.Word.WdSaveFormat.wdFormatPDF;
//保存为新文件
//object oNewFileName = Server.MapPath(newFileName);
WordDoc.SaveAs(ref PdfFilePath, FileFormat, ref Missing, ref Missing, ref Missing, ref Missing, ref Missing,
ref Missing, ref Missing, ref Missing, ref Missing, ref Missing, ref Missing, ref Missing, ref Missing, ref Missing);
WordDoc.Close(ref Missing, ref Missing, ref Missing);
WordApp.Quit(ref Missing, ref Missing, ref Missing);
return true;
}

catch (Exception e)
{
MessageBox.Show(e.Message.ToString());
return false;

}
}

合併Word
public static bool MergeWord(string[] InFilePath,string OutFilePath)
{
try
{
object missing = Missing.Value;
object iLastWord = InFilePath.Last();//最後合併的word
object oOutputDoc = OutFilePath;//合併檔
object oPageBreak = Word.WdBreakType.wdSectionBreakContinuous;
//object oPageBreak = Word.WdBreakType.wdLineBreak;//接下行合併(LineBreak)
//object oPageBreak = Word.WdBreakType.wdPageBreak;//接下頁合併(PageBreak)

Word.Application wordApp = new Word.Application();

Word.Document origDoc = wordApp.Documents.Open(ref iLastWord, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing);
origDoc.Activate();

for (int i = 0; i < InFilePath.Count();i++)
{
if (i == (InFilePath.Count() - 1) || InFilePath.Count() == 0)
break;
wordApp.Selection.InsertFile(InFilePath[i], ref missing, ref missing, ref missing, ref missing);
wordApp.Selection.InsertBreak(ref oPageBreak);
}

wordApp.ActiveDocument.SaveAs(ref oOutputDoc, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing);
wordApp.ActiveDocument.Close(ref missing, ref missing, ref missing);
wordApp.Quit(ref missing, ref missing, ref missing); //加這行可以 Kill WINWORD.EXE process

return true;
}
catch
{
return false;
}
}

下載MS檔案
public static bool DownloadFile(string FilePath,string NewFileName, HttpResponse response)
{
try
{
FileInfo DownloadFile = new FileInfo(FilePath);
response.Clear();
response.ClearHeaders();
response.Buffer = false;
//Response.ContentType指定檔案類型
//可以為application/ms-excel || application/ms-word || application/ms-txt
//application/ms-html || 或其他瀏覽器可以支援的文件
response.ContentType = "application/octet-stream";//所有類型
//下面這行很重要, attachment 参数表示作為附件下載,可以改成 online線上開啟
//filename=FileFlow.xls 指定输出檔案名稱,注意其附檔名和指定檔案類型相符,
//可以為:.doc || .xls || .txt ||.htm
response.AppendHeader("Content-Disposition", "attachment;filename=" + HttpUtility.UrlEncode(NewFileName, System.Text.Encoding.UTF8));
response.AppendHeader("Content-Length", DownloadFile.Length.ToString());//取得檔案大小

response.WriteFile(DownloadFile.FullName);
response.Flush();
response.End();

return true;
}
catch
{
return false;
}
}

The Will Will Web

技術分享
MVP版主

重灌狂人

資訊分享

wowboxBlog

提供網頁設計相關資訊

KingKong Bruce記事

技術分享

C# Examples

csharp相關技術與範例

黑暗執行緒

技術分享
MVP版主

杨延成

技術分享
作者文章對於EF有詳細介紹

月光下的嘆息

工具分享
介紹許多好用的工具程式

Dot blogs

DotNet

格子樑/艾倫郭

技術分享
MVP版主