C# - Math.Round,好像是四捨六入呢?
要加上MidpointRounding.AwayFromZero才會真的四捨五入
using System;
using System.CodeDom.Compiler;
using System.Reflection;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
///
/// Evaluator 的摘要描述
///
public class Evaluator
{
public static object Eval(string statement)
{
return _evaluatorType.InvokeMember("Eval", BindingFlags.InvokeMethod, null, _evaluator, new object[] { statement });
}
static Evaluator()
{
CodeDomProvider provider = CodeDomProvider.CreateProvider("JScript");
CompilerParameters parameters;
parameters = new CompilerParameters();
parameters.GenerateInMemory = true;
CompilerResults results;
results = provider.CompileAssemblyFromSource(parameters, _jscriptSource);
Assembly assembly = results.CompiledAssembly;
_evaluatorType = assembly.GetType("Evaluator");
_evaluator = Activator.CreateInstance(_evaluatorType);
}
private static readonly object _evaluator;
private static readonly Type _evaluatorType;
private static readonly string _jscriptSource = @"class Evaluator { public function Eval(expr : String) : String { return eval(expr); } }";
}
string pattern = Regex.Escape("(") + "(.*?)" + Regex.Escape(")");
string input = "(02)1234567";
MatchCollection matches = Regex.Matches(input, pattern);
foreach (Match match in matches)
{
MessageBox.Show(match.Value);
}
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Microsoft.SharePoint.Administration;
namespace SPSDashBoard
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
SPWebService contentService = SPWebService.ContentService;
SPDeveloperDashboardSettings developerDashboard =
contentService.DeveloperDashboardSettings;
developerDashboard.DisplayLevel = SPDeveloperDashboardLevel.On; //關閉是Off
developerDashboard.Update();
MessageBox.Show("Developer Dashboard updated.");
}
}
}