protected void btn_Save_Click(object sender, EventArgs e) { if (SLP_ITEM.Text != "" && Page.Request.Form[SLP_ITEM.TextBox_Name.UniqueID] != "查無資料" && Page.Request.Form[SLP_ITEM.TextBox_Name.UniqueID] != "" && SLP_PERIOD.Text != "") { //string SessionID = string.Format("PUR041_MST_{0}", Request.QueryString["PageTimeStamp"]); //DataTable DetailDt = (DataTable)Session[SessionID]; //DataRow[] drs = DetailDt.Select("VIRTUAL_CODE = '" + SLP_ITEM.Text + "' and PERIOD = '" + SLP_PERIOD.Text + "'"); //if (drs.Length > 0) // DetailDt.Rows[0].Delete(); ArrayList ar = new ArrayList(); ar.Add(SLP_ITEM.Text); ar.Add(SLP_PERIOD.Text); string SessionID = string.Format("PUR041_DEL_{0}", Request.QueryString["PageTimeStamp"]); Session[SessionID] = ar; ViewState["IsSave"] = "1"; ScriptManager.RegisterStartupScript(this, this.GetType(), "", "window.close();", true); } else { if (SLP_ITEM.Text == "" && SLP_PERIOD.Text == "") ErrorMsgLabel.Text = "請輸入品號、期別"; else if (SLP_ITEM.Text == "" || SLP_ITEM.TextBox_Name.Text == "查無資料" || SLP_ITEM.TextBox_Name.Text == "") ErrorMsgLabel.Text = "請輸入正確品號"; else if(SLP_PERIOD.Text == "") ErrorMsgLabel.Text = "請輸入正確期別"; } }
void Update() { ArrayList list = new ArrayList (); DeviceOrientation orientation = Input.deviceOrientation; if (_lastOrientation != orientation) { switch (orientation) { case DeviceOrientation.LandscapeLeft: case DeviceOrientation.LandscapeRight: case DeviceOrientation.Portrait: case DeviceOrientation.PortraitUpsideDown: list.Add (new FageScreenEvent (_lastOrientation, Input.deviceOrientation)); _lastOrientation = orientation; break; } } if ((_lastWidth != Screen.width) || (_lastHeight != Screen.height)) { list.Add (new FageScreenEvent (_lastWidth, _lastHeight, Screen.width, Screen.height)); _lastWidth = Screen.width; _lastHeight = Screen.height; } if (_lastDpi != Screen.dpi) { list.Add (new FageScreenEvent (_lastDpi, Screen.dpi)); _lastDpi = Screen.dpi; } foreach (FageScreenEvent fsevent in list) { DispatchEvent(fsevent); } }
public string GiftName(string Code, string ITEM, string PERIOD ) { string Name = ""; string ConnectionDBStr = ((DatabaseSettings)ConfigurationManager.GetSection("dataConfiguration")).DefaultDatabase; MaintainGift bcoGift = new MaintainGift(ConnectionDBStr); if (Code != "") { ArrayList ParameterList = new ArrayList(); ParameterList.Clear(); ParameterList.Add(Code); ParameterList.Add(ITEM); ParameterList.Add(PERIOD); DataTable dt = bcoGift.QueryForSLP(ParameterList); Name = ((dt.Rows.Count > 0) ? dt.Rows[0]["VIRTUAL_NAME"].ToString() : "查無資料"); } return Name; }
public ArrayList GetFactionTopList( PlayerMobile from ) { ArrayList members = new ArrayList(); foreach ( PlayerState playerstate in CouncilOfMages.Instance.Members ) { members.Add( playerstate ); } foreach ( PlayerState playerstate in Shadowlords.Instance.Members ) { members.Add( playerstate ); } //Edit begin foreach ( PlayerState playerstate in Minax.Instance.Members ) { members.Add( playerstate ); } foreach ( PlayerState playerstate in TrueBritannians.Instance.Members ) { members.Add( playerstate ); } //Edit end WorstFactionScoreComparer comparer = new WorstFactionScoreComparer(); members.Sort( comparer ); return members; }
public int howMany(int n) { ArrayList fibs = new ArrayList(); int[] dist = new int[1000001]; int fib1 = 1; int fib2 = 1; fibs.Add(1); dist[0] = 0; while (fib2 <= n) { int next = fib1 + fib2; if (next > 1000000) break; fibs.Add(next); fib1 = fib2; fib2 = next; } for (int i = 1; i <= n; i++) { int best = int.MaxValue; foreach (int j in fibs) { if (j > i) break; int ind = i - j; int next = dist[ind] + 1; if (next < best) best = next; } dist[i] = best; } return dist[n]; }
public ArrayList getConfig() { ArrayList list = new ArrayList(); list.Add(_nameObjectToHide); list.Add(_hide); return list; }
protected void bttnChangeTribeInfo_Click(object sender, EventArgs e) { this.tribe.Tag = this.txtTag.Text; this.tribe.Name = this.txtName.Text; this.tribe.Description = this.txtDescription.Content; if (this.fileAvatar.HasFile) { ArrayList lstExtension = new ArrayList(); lstExtension.Add(".jpg"); lstExtension.Add(".gif"); lstExtension.Add(".png"); lstExtension.Add(".jpeg"); string filename = fileAvatar.FileName; if (!lstExtension.Contains(Path.GetExtension(filename).ToLower())) this.lblAvatarError.Text = "Định dạng file ảnh phải là jpg"; else if (!Functions.UploadImage(fileAvatar.FileContent, Server.MapPath("~/data/images/tribe/") + this.tribe.ID.ToString() + ".jpg")) this.lblAvatarError.Text = "File không đúng định dạng. Vui lòng thử lại với ảnh khác"; else this.tribe.Avatar = true; } ISession session = (ISession)Context.Items[Constant.NHibernateSessionSign]; session.Update(this.tribe); Response.Redirect("tribe.aspx?id=" + this.village.ID.ToString(), true); }
public virtual ParticulaDibujable[] GeneraDibujables(Particula[] particula,float[] color,bool aleat) { ArrayList result=new ArrayList(); for (int i = 0; i < particula.Length; i++) { if(particula[i]==null)return (ParticulaDibujable[])result.ToArray(Type.GetType("ParticulaDibujable")); try { if(tempInfo==null || tempInfo.Nombre!=particula[i].GetType().Name) { tempInfo=pinfo.GetInfoParticulas(particula[i].GetType().Name); } } catch (Exception ex) { throw new Exception("Error al Generar Particulas Dibujables"); } assem=GestorEnsamblados.GetAssemblyByName(tempInfo.EnsambladoDibujable,tempInfo.PathDibujable); if(aleat) { result.Add((ParticulaDibujable)assem.CreateInstance(tempInfo.NombreDibujable, true, BindingFlags.CreateInstance, null, new object[] {particula[i]}, null, null)); } else { result.Add((ParticulaDibujable)assem.CreateInstance(tempInfo.NombreDibujable, true, BindingFlags.CreateInstance, null, new object[] {particula[i], color}, null, null)); } } return (ParticulaDibujable[])result.ToArray(Type.GetType("ParticulaDibujable")); }
// Use this for initialization void Start() { items = new ArrayList(); items.Add(number3); items.Add (number2); items.Add(number1); }
public void testCount() { IList<string> list = new ArrayList<string>(); list.Add("hoi"); list.Add("noot"); AssertEquals(2, list.Count); }
protected void page_init(object sender, EventArgs e) { try { ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "globalServicePath", " var aspxservicePath='" + ResolveUrl("~/") + "Modules/ASPXCommerce/ASPXCommerceServices/" + "';", true); lblRepairInstallHelp.Text = SageMessage.GetSageModuleLocalMessageByVertualPath("Modules/ASPXCommerce/ASPXPaymentGateWayManagement/ModuleLocalText", "WarningMessageWillDeleteAllFiles"); chkRepairInstall.Checked = true; //chkRepairInstall.Enabled = false; pnlRepair.Visible = true; InitializeJS(); string strTemplatePath = ""; ArrayList cssList = new ArrayList(); cssList.Add("~/Templates/" + TemplateName + "/css/GridView/tablesort.css"); cssList.Add("~/Templates/" + TemplateName + "/css/MessageBox/style.css"); cssList.Add("~/Templates/" + TemplateName + "/css/PopUp/style.css"); foreach (string css in cssList) { strTemplatePath = css; IncludeCssFile(strTemplatePath); } } catch (Exception ex) { ProcessException(ex); } }
protected void FirstParseEl(string text,int position,ArrayList ar) { if(position < text.Length) { if(text[position]==' ') FirstParseEl(text,position+1,ar); else { if(IsSlovo(text,position)!=-1) { ar.Add(new Slovo(text.Substring(position,IsSlovo(text,position)-position), ChastRechi.Neopredelennaya,false)); FirstParseEl(text,IsSlovo(text,position),ar); } else { if(position+3<text.Length&&text.Substring(position,3)=="...") { ar.Add(new Slovo("...", ChastRechi.Znak,false)); FirstParseEl(text,position+3,ar); } else { ar.Add(new Slovo(text.Substring(position,1), ChastRechi.Znak,false)); FirstParseEl(text,position+1,ar); } } } } else return; }
/* ============================================================================ Data handling functions ============================================================================ */ public Hashtable GetData(Hashtable ht) { if(this.active) { ArrayList s = new ArrayList(); ht.Add("distance", this.distance.ToString()); ht.Add("layermask", this.layerMask.ToString()); if(this.ignoreUser) ht.Add("ignoreuser", "true"); ht = this.mouseTouch.GetData(ht); ht.Add("rayorigin", this.rayOrigin.ToString()); VectorHelper.ToHashtable(ref ht, this.offset); if(TargetRayOrigin.USER.Equals(this.rayOrigin)) { s.Add(HashtableHelper.GetContentHashtable(TargetRaycast.CHILD, this.pathToChild)); if(!this.mouseTouch.Active()) { VectorHelper.ToHashtable(ref ht, this.rayDirection, "dx", "dy", "dz"); } } s.Add(HashtableHelper.GetContentHashtable(TargetRaycast.TARGETCHILD, this.pathToTarget)); VectorHelper.ToHashtable(ref ht, this.targetOffset, "tx", "ty", "tz"); if(s.Count > 0) ht.Add(XMLHandler.NODES, s); } return ht; }
public void fill4(int x, int y, Color32 oldColor, Color32 newColor) { ArrayList stack = new ArrayList(); stack.Add(new Vec2i(x,y)); int emergency = 10000; while(stack.Count > 0 && emergency >= 0) { Vec2i pixel = (Vec2i)stack[stack.Count - 1]; stack.RemoveAt(stack.Count - 1); if(canvas.GetPixel(pixel.x, pixel.y) == oldColor) { canvas.SetPixel(pixel.x, pixel.y, newColor); if(pixel.x + 1 < 96 && canvas.GetPixel(pixel.x + 1, pixel.y) == oldColor) stack.Add(new Vec2i(pixel.x + 1, pixel.y)); if(pixel.x - 1 >= 0 && canvas.GetPixel(pixel.x - 1, pixel.y) == oldColor) stack.Add(new Vec2i(pixel.x - 1, pixel.y)); if(pixel.y + 1 < 64 && canvas.GetPixel(pixel.x, pixel.y + 1) == oldColor) stack.Add(new Vec2i(pixel.x, pixel.y + 1)); if(pixel.y - 1 >= 0 && canvas.GetPixel(pixel.x, pixel.y - 1) == oldColor) stack.Add(new Vec2i(pixel.x, pixel.y - 1)); } emergency--; } }
public Node getNext() { //transform.position= new Vector3(0, target[0], target[1]); ArrayList list = new ArrayList (); ArrayList popularity = new ArrayList (); while (true) { int randomNumber = (int)Random.Range (0, 4); Debug.Log (randomNumber); if (n != null && randomNumber == 0) { list.Add (n); popularity.Add (n.popularity); return n; } if (e != null&& randomNumber == 1) { list.Add (e); popularity.Add (e.popularity); return e; } if (s != null&& randomNumber == 2) { list.Add (s); popularity.Add (s.popularity); return s; } if (w != null&& randomNumber == 3) { list.Add (w); popularity.Add (w.popularity); return w; } } return null; //perform the algorithm here, biased against turning around //for (int i=0; i<list.Count; i++) { //} //return null; }
private void recursiveBlockDivision(Block block, ArrayList blocks, int loopsLeft) { if (loopsLeft < 0) { return; } float currentMagnitude = (block.c3 - block.c1).magnitude; Block[] newBlocks = subDivideBlock (block); bool subDivide; if (Mathf.Max ((block.c2 - block.c1).magnitude, (block.c4 - block.c1).magnitude) > maximumBlockSize) { //block too large, subdivide subDivide = true; } else if (newBlocks [0].IsNull) { //block can be subdivided, keep it like this subDivide = false; blocks.Add (block); } else { if (currentMagnitude < minimumBlockSize * 6 && Random.value <= 0.2) { subDivide = false; } else if (Random.value <= 0.2) { subDivide = false; blocks.Add (block); } else { subDivide = true; } } if (subDivide) { recursiveBlockDivision (newBlocks [0], blocks, loopsLeft - 1); recursiveBlockDivision (newBlocks [1], blocks, loopsLeft - 1); } }
protected void Page_Init(object sender, EventArgs e) { try { userIP = HttpContext.Current.Request.UserHostAddress; IPAddressToCountryResolver ipToCountry = new IPAddressToCountryResolver(); ipToCountry.GetCountry(userIP, out countryName); InitializeJS(); string strTemplatePath = ""; ArrayList cssList = new ArrayList(); cssList.Add("~/Templates/" + TemplateName + "/css/GridView/tablesort.css"); cssList.Add("~/Templates/" + TemplateName + "/css/MessageBox/style.css"); cssList.Add("~/Templates/" + TemplateName + "/css/StarRating/jquery.rating.css"); foreach (string css in cssList) { strTemplatePath = css; IncludeCssFile(strTemplatePath); } } catch (Exception ex) { ProcessException(ex); } }
// Use this for initialization void Start() { ArrayList list = new ArrayList (); int score = PlayerPrefs.GetInt ("endScore"); for (int i = 1; i<=10; i++) { key = "highScore" + i; keyscore = PlayerPrefs.GetInt(key); list.Add(keyscore); //PlayerPrefs.SetInt (key, 0); } lowestScore = PlayerPrefs.GetInt ("highScore10"); Debug.Log ("lowest score" + lowestScore); if (score > lowestScore) { list.Add (score); list.Sort (); list.Reverse(); list.RemoveAt(10); for (int i = 1; i<=10; i++) { key = "highScore" + i; PlayerPrefs.SetInt(key, (int)list[i-1]); } } }
GameObject getRandomTarget() { ArrayList myList = new ArrayList(); GameObject[] targets; GameObject random=null; targets=GameObject.FindGameObjectsWithTag("Slayer"); foreach (GameObject go in targets) { myList.Add(go); } targets=GameObject.FindGameObjectsWithTag("Vampire"); foreach (GameObject go in targets) { myList.Add(go); } if(myList.Count>0) { int randomNumber=Random.Range(0,myList.Count); for(int i=0; i<myList.Count; i++) { random=(GameObject)myList[randomNumber]; } } if(random==null) {return null;} return random; }
public string GetDoName(string Code, string Z_O ) { string Name = ""; string ConnectionDBStr = ((DatabaseSettings)ConfigurationManager.GetSection("dataConfiguration")).DefaultDatabase; MaintainDoBase co_main = new MaintainDoBase(ConnectionDBStr); if (Code != "") { ArrayList ParameterList = new ArrayList(); ParameterList.Clear(); ParameterList.Add(Code); ParameterList.Add(Z_O); DataTable Dt = co_main.QueryForSLP(ParameterList); if (Dt.Rows.Count > 0) { Name = Dt.Rows[0]["CODE_NAME"].ToString().Trim(); } else { Name = "查無資料"; } } return Name; }
/// <summary> /// creates 1 correct answer and several incorrect answers for the task /// </summary> //TODO: improve random incorrect solutions + avoid doubled answers private ArrayList createOptions() { float solution = problem.getSolution(); ArrayList newOptions = new ArrayList(); MathOption correctOption = new MathOption(solution, true); newOptions.Add(correctOption); for (int i = 0; i < amountOfOptions; i++) { int incorrectSolution = rnd.Next(1, 400); while (incorrectSolution == solution) //avoids the correct solution occuring additionally as incorrect solution { incorrectSolution = rnd.Next(1, 400); } newOptions.Add(new MathOption(incorrectSolution)); } //giving the correct answer a random index int index = rnd.Next(0, 11); MathOption transAnswer = (MathOption)newOptions[index]; newOptions[0] = transAnswer; newOptions[index] = correctOption; return newOptions; }
internal static ArrayList run(IList para) { bool reverse = false; modshogun.init_shogun_with_defaults(); int order = (int)((int?)para[0]); int gap = (int)((int?)para[1]); string[] fm_train_dna = Load.load_dna("../data/fm_train_dna.dat"); StringCharFeatures charfeat = new StringCharFeatures(fm_train_dna, DNA); StringWordFeatures feats = new StringWordFeatures(charfeat.get_alphabet()); feats.obtain_from_char(charfeat, order-1, order, gap, reverse); Histogram histo = new Histogram(feats); histo.train(); histo.get_histogram(); int num_examples = feats.get_num_vectors(); int num_param = histo.get_num_model_parameters(); DoubleMatrix out_likelihood = histo.get_log_likelihood(); double out_sample = histo.get_log_likelihood_sample(); ArrayList result = new ArrayList(); result.Add(histo); result.Add(out_sample); result.Add(out_likelihood); modshogun.exit_shogun(); return result; }
internal static ArrayList run(IList para) { modshogun.init_shogun_with_defaults(); int degree = (int)((int?)para[0]); string[] fm_train_dna = Load.load_dna("../data/fm_train_dna.dat"); string[] fm_test_dna = Load.load_dna("../data/fm_test_dna.dat"); StringCharFeatures feats_train = new StringCharFeatures(fm_train_dna, DNA); StringCharFeatures feats_test = new StringCharFeatures(fm_test_dna, DNA); WeightedDegreePositionStringKernel kernel = new WeightedDegreePositionStringKernel(feats_train, feats_train, degree); kernel.set_position_weights(DoubleMatrix.ones(1, (fm_train_dna[0]).Length)); DoubleMatrix km_train = kernel.get_kernel_matrix(); kernel.init(feats_train, feats_test); DoubleMatrix km_test = kernel.get_kernel_matrix(); ArrayList result = new ArrayList(); result.Add(km_train); result.Add(km_test); result.Add(kernel); modshogun.exit_shogun(); return result; }
public static void Prepare(string section, string action, Dictionary<String, String> postdata, out string url, out WWWForm post) { var r = new System.Random(); url = URL + "&r=" + r.Next(10000000) + "Z"; var timestamp = (DateTime.Now.Subtract(new DateTime(1970, 1, 1, 0, 0, 0))).TotalSeconds.ToString(); var nonce = Playtomic_Encode.MD5(timestamp + Playtomic.SourceUrl + Playtomic.GameGuid); var pd = new ArrayList(); pd.Add("nonce=" + nonce); pd.Add("timestamp=" + timestamp); if(postdata != null) foreach(string key in postdata.Keys) pd.Add(key + "=" + Escape(postdata[key])); GenerateKey("section", section, ref pd); GenerateKey("action", action, ref pd); GenerateKey("signature", nonce + timestamp + section + action + url + Playtomic.GameGuid, ref pd); var joined = ""; foreach(var item in pd) joined += (joined == "" ? "" : "&") + item; post = new WWWForm(); post.AddField("data", Escape(Playtomic_Encode.Base64(joined))); }
protected override ArrayList GetPossibleRoutines(int hour, int minute) { ArrayList possibleRoutines = new ArrayList(); int wakingHour = Random.Range(14, 17); CharacterState state = GetComponent(typeof(CharacterState)) as CharacterState; if (state.GetDrunkness() >= MAXIMUM_DRUNKNESS && hour < 2 && hour >= wakingHour){ possibleRoutines.Add(new StandAroundAction(gameObject, 20.0f, "Deck Railing Waypoints")); } if (hour >= wakingHour && hour < 17){ //Lobby/deck possibleRoutines.Add(new StandAroundAction(gameObject, 3, "Lobby Display Waypoints")); possibleRoutines.Add(new StandAroundAction(gameObject, 20.0f, "Deck Railing Waypoints")); possibleRoutines.Add(new FollowAction(gameObject, CharacterManager.GetMajorNPC("Chris"), FollowAction.Reason.NPC, true)); //possibleRoutines.Add(new WanderAction(gameObject, 3, "Deck Connecting Waypoints")); } else if (hour >= 17 && hour < 18){ //Dinner (Ed's breakfast) possibleRoutines.Add(new EatAction(gameObject, "Chair: Ed")); } else if (hour >= 18 && hour < 20){ //restaurant idle/gamble possibleRoutines.Add(new BuyItemAction(gameObject, "beer", "Waypoint: Restaurant Shopkeeper")); possibleRoutines.Add(new StandAroundAction(gameObject, 20.0f, "Restaurant Window Waypoints")); possibleRoutines.Add(new FollowAction(gameObject, CharacterManager.GetMajorNPC("Chris"), FollowAction.Reason.NPC, true)); //possibleRoutines.Add(new NPCPokerAction()); } else if (hour >= 20 || hour < 2){ //disco possibleRoutines.Add(new BuyItemAction(gameObject, "beer", "Waypoint: Disco Shopkeeper")); } else { //sleep possibleRoutines.Add(new IdleAction(gameObject, 1.0f, GameObject.Find("Waypoint: Cabin: Ed"), DistanceConstants.WAYPOINT_RADIUS, false)); } return possibleRoutines; }
internal static ArrayList run(IList para) { modshogun.init_shogun_with_defaults(); int degree = (int)((int?)para[0]); string[] fm_train_dna = Load.load_dna("../data/fm_train_dna.dat"); string[] fm_test_dna = Load.load_dna("../data/fm_test_dna.dat"); StringCharFeatures feats_train = new StringCharFeatures(fm_train_dna, DNA); StringCharFeatures feats_test = new StringCharFeatures(fm_test_dna, DNA); WeightedDegreeStringKernel kernel = new WeightedDegreeStringKernel(feats_train, feats_train, degree); double[] w = new double[degree]; double sum = degree * (degree + 1)/2; for (int i = 0; i < degree; i++) { w[i] = (degree - i)/sum; } DoubleMatrix weights = new DoubleMatrix(1, degree, w); kernel.set_wd_weights(weights); DoubleMatrix km_train = kernel.get_kernel_matrix(); kernel.init(feats_train, feats_test); DoubleMatrix km_test = kernel.get_kernel_matrix(); ArrayList result = new ArrayList(); result.Add(km_train); result.Add(km_test); result.Add(kernel); modshogun.exit_shogun(); return result; }
public static ArrayList GetAllChildren(GameObject parentGameObject, string[] excludeSubstrings, bool includeParent = false) { //returns an arraylist of all children, grandchildren, etc. //excludes all objects and their children if their name contains any string in excludeSubstrings ArrayList children = new ArrayList(); if (includeParent) children.Add(parentGameObject); for (int i = 0; i < parentGameObject.transform.childCount; i++) { GameObject child = parentGameObject.transform.GetChild(i).gameObject; bool excludeChild = false; foreach (string substring in excludeSubstrings) { if (child.name.Contains(substring)) { excludeChild = true; break; } } if (excludeChild) continue; children.Add(child); if (child.transform.childCount > 0) children.AddRange(GetAllChildren(child, excludeSubstrings, false)); } return children; }
}//Page_Load private void QueryData() { #region //抓取本頁初次登記的時間 string SessionIDName = string.Format("{0}_{1}", PAGE_DT_01, PageTimeStamp.Value); ALOModel.MaintainDisParameter BCO = new ALOModel.MaintainDisParameter(ConnectionDB); ArrayList ParameterList = new ArrayList();//20091113 ParameterList.Clear(); TextBoxCode.Text = TextBoxCode.Text + "%"; TextBoxName.Text = TextBoxName.Text + "%"; ParameterList.Add(TextBoxCode.Text); ParameterList.Add(TextBoxName.Text); ParameterList.Add(TextBoxRowCountLimit.Text.Trim()); DataTable Dt = BCO.QuerySwitch(ALOModel.ALOCommon.QueryType.QryFileForSLP, ParameterList); Session[SessionIDName] = Dt; GridView1.DataSource = Dt; //設定分頁大小 GridView1.PageSize = (TextBoxPagesize.Text == "") ? 10 : (int.Parse(TextBoxPagesize.Text) <= 0) ? 10 : int.Parse(TextBoxPagesize.Text); GridView1.PageIndex = 0; GridView1.DataBind(); GridView1.SelectedIndex = -1; LabelQueryRecordCount.Text = string.Format(" {0} Rows ", Dt.Rows.Count.ToString()); #endregion }
protected void Page_Load(object sender, EventArgs e) { ArrayList data1 = new ArrayList(); Random rand = new Random(DateTime.Now.Millisecond); for (double i = 0; i < 12; i++) { int temp = rand.Next(30); if (temp > 20) data1.Add(new LineDotValue(temp, "#fe0")); else { data1.Add(temp); } } line1.Values = data1; line1.HaloSize = 0; line1.Width = 2; line1.DotSize = 5; line1.Tooltip = "提示:#val#"; chart.AddElement(line1); chart.Title = new Title("line演示"); chart.Y_Axis.SetRange(0, 35, 5); chart.Tooltip = new ToolTip("全局提示:#val#"); chart.Tooltip.Shadow = true; chart.Tooltip.Colour = "#e43456"; chart.Tooltip.MouseStyle = ToolTipStyle.CLOSEST; OpenFlashChartControl1.EnableCache = false; OpenFlashChartControl1.Chart = chart; }
internal static ArrayList run(IList para) { bool reverse = false; modshogun.init_shogun_with_defaults(); int order = (int)((int?)para[0]); int gap = (int)((int?)para[1]); int degree = (int)((int?)para[2]); string[] fm_train_dna = Load.load_dna("../data/fm_train_dna.dat"); string[] fm_test_dna = Load.load_dna("../data/fm_test_dna.dat"); StringCharFeatures charfeat = new StringCharFeatures(fm_train_dna, DNA); StringWordFeatures feats_train = new StringWordFeatures(charfeat.get_alphabet()); feats_train.obtain_from_char(charfeat, order-1, order, gap, false); charfeat = new StringCharFeatures(fm_test_dna, DNA); StringWordFeatures feats_test = new StringWordFeatures(charfeat.get_alphabet()); feats_test.obtain_from_char(charfeat, order-1, order, gap, false); PolyMatchWordStringKernel kernel = new PolyMatchWordStringKernel(feats_train, feats_train, degree, true); DoubleMatrix km_train = kernel.get_kernel_matrix(); kernel.init(feats_train, feats_test); DoubleMatrix km_test =kernel.get_kernel_matrix(); ArrayList result = new ArrayList(); result.Add(km_train); result.Add(km_test); result.Add(kernel); modshogun.exit_shogun(); return result; }
static void Main(string[] args) { ArrayList a = null; a?.Add("야구"); a?.Add("축구"); WriteLine($"Count : {a?.Count}"); WriteLine($"{a?[0]}"); WriteLine($"{a?[1]}"); a = new ArrayList(); a?.Add("야구"); a?.Add("축구"); WriteLine($"Count : {a?.Count}"); WriteLine($"{a?[0]}"); WriteLine($"{a?[1]}"); }
static void Main(string[] args) { ArrayList a = null; a?.Add("야구"); // a?.이 null을 반환하므로 Add() 메소드는 호출되지 않음 a?.Add("축구"); WriteLine($"Count : a{a?.Count}"); WriteLine($"{a?[0]}"); WriteLine($"{a?[1]}"); a = new ArrayList(); //a a는 이제 더 이상 null이 아닙니다. a?.Add("야구"); a?.Add("축구"); WriteLine($"Count : {a?.Count}"); WriteLine($"{a?[0]}"); WriteLine($"{a?[1]}"); }
static void Main(string[] args) { ArrayList a = null; a?.Add("야구"); a?.Add("축구"); //a가 null이므로 Count : 이외에는 아무것도 출력되지 않음 WriteLine($"count : {a?.Count}"); WriteLine($"{a?[0]}"); WriteLine($"{a?[1]}"); a = new ArrayList(); a?.Add("야구"); a?.Add("축구"); WriteLine($"count : {a?.Count}"); WriteLine($"{a?[0]}"); WriteLine($"{a?[1]}"); }
private static void NullConditionalOperator() { WriteLine("\nNullConditionalOperator()"); ArrayList arr = null; arr?.Add("야구"); arr?.Add("축구"); WriteLine($"Count : {arr?.Count}"); WriteLine($"{arr[0]}"); WriteLine($"{arr[1]}"); arr = new ArrayList(); arr?.Add("야구"); arr?.Add("축구"); WriteLine($"Count : {arr?.Count}"); WriteLine($"{arr[0]}"); WriteLine($"{arr[1]}"); }
{ // 널 조건부 연산자 static void Main(string[] args) { ArrayList a = null; a?.Add("야구"); // a?.이 null을 반환하므로 Add() 메소드는 호출되지 않음 a?.Add("축구"); Console.WriteLine($"Count : {a?.Count}"); Console.WriteLine($"{a?[0]}"); Console.WriteLine($"{a?[1]}"); a = new ArrayList(); // a는 이제 null이 아님 a?.Add("야구"); a?.Add("축구"); Console.WriteLine($"Count : {a?.Count}"); Console.WriteLine($"{a?[0]}"); Console.WriteLine($"{a?[1]}"); }
static void print_08() { Controll_String cs = null; Controll_String cs2 = new Controll_String(); cs2.member = 10; int?bar; if (cs == null) { bar = null; } else { bar = cs.member; } WriteLine(bar); bar = cs2?.member; //cs?는 cs객체가 널이 아니면 멤버변수에 접근 WriteLine(bar); //'?[]'을 이용한 배열과 같은 컬렉션 객체 사용 ArrayList a = null; WriteLine("ArrayList 객체인 a 에Null 객체 생성"); a?.Add("야구"); a?.Add("축구"); WriteLine($"Count: {a?.Count}"); WriteLine($"{a?[0]}"); WriteLine($"{a?[1]}"); WriteLine("ArrayList 객체인 a 에 ArrayList 객체 생성"); a = new ArrayList(); a?.Add("야구"); a?.Add("축구"); WriteLine($"Count: {a?.Count}"); WriteLine($"{a?[0]}"); WriteLine($"{a?[1]}"); }
static void Main(string[] args) { ArrayList a = null; a?.Add("야구"); // a?.가 null을 반환하므로 add() 메소드는 호출되지 않음 a?.Add("축구"); WriteLine($"Count: {a?.Count}"); // a?.가 null을 Count만 출력됨 WriteLine($"{a?[0]}"); WriteLine($"{a?[1]}"); a = new ArrayList(); // a는 더이상 null이 아니다. a?.Add("야구"); a?.Add("축구"); WriteLine($"Count: {a?.Count}"); WriteLine($"{a?[0]}"); WriteLine($"{a?[1]}"); }
static void Main(string[] args) { ArrayList a = null; a?.Add("a"); a?.Add("b"); Console.WriteLine("Count : {0}", a?.Count); Console.WriteLine(a?[0]); Console.WriteLine(a?[1]); a = new ArrayList(); a?.Add("a"); a?.Add("b"); Console.WriteLine(a?.Count); Console.WriteLine(a?[0]); Console.WriteLine(a?[1]); int a2 = 19; }
public static void Main(string[] args) { // Null 조건부 연산자 Foo foo = new Foo(); int? bar; //if (foo == null) // bar = null; //else // bar = foo.Member; bar = foo?.Member; Console.WriteLine(bar); ArrayList arr = null; arr?.Add("야구"); arr?.Add("축구"); Console.WriteLine(arr?.Count); Console.WriteLine(arr?[0]); Console.WriteLine(arr?[1]); arr = new ArrayList(); arr?.Add("야구"); arr?.Add("축구"); Console.WriteLine(arr?.Count); Console.WriteLine(arr?[0]); Console.WriteLine(arr?[1]); int? a = null; Console.WriteLine($"{a ?? 0}"); a = 100; Console.WriteLine($"{a ?? 0}"); }
static void Main(string[] args) { // Null 조건부 연산자 Foo foo = new Foo(); int?bar; // Nullable 변수 선언: null 을 저장할 수 있는 변수가 됨. //if (foo == null) // bar = null; //else // bar = foo.member; bar = foo?.member; // foo가 null이 아니면 member 변수값 할당, 아니면 null Console.WriteLine(bar); ArrayList arr = null; arr?.Add("야구"); arr?.Add("축구"); Console.WriteLine(arr?.Count); Console.WriteLine(arr?[0]); Console.WriteLine(arr?[1]); arr = new ArrayList(); arr?.Add("야구"); arr?.Add("축구"); Console.WriteLine(arr?.Count); Console.WriteLine(arr?[0]); Console.WriteLine(arr?[1]); int?a = null; Console.WriteLine($"{a ?? 0}"); a = 100; Console.WriteLine($"{a ?? 0}"); }
static void Main(string[] args) { // Null 조건부 연산자 Foo foo = new Foo(); int?bar; //Nullable 변수 선언: null을 저장할 수 있는 변수가 됨 /*if (foo == null) * bar = null; * else * bar = foo.member;*/ bar = foo?.member; //foo가 null이 아니면 member 변수값 할당, 아니면 null Console.WriteLine(bar); ArrayList arr = null; arr?.Add("야구"); arr?.Add("축구"); Console.WriteLine(arr?.Count); Console.WriteLine(arr?[0]); Console.WriteLine(arr?[1]); arr = new ArrayList(); arr?.Add("야구"); arr?.Add("축구"); Console.WriteLine(arr?.Count); Console.WriteLine(arr?[0]); Console.WriteLine(arr?[1]); int?a = null; Console.WriteLine($"{a ?? 0}"); //null이면 오른쪽 값이 나옴(null일 경우 결과: 0 || null이 아닐 경우: a값) a = 100; Console.WriteLine($"{a ?? 0}"); }
static void Main(string[] args) { /*********** null 조건부 연산자 **********/ ArrayList arr = null; arr?.Add("야구"); arr?.Add("축구"); Console.WriteLine(arr?.Count); Console.WriteLine(arr?[0]); arr = new ArrayList(); arr?.Add("야구"); arr?.Add("축구"); Console.WriteLine(arr?.Count); Console.WriteLine(arr?[0]); /*********** null 병합 연산자 **********/ int?a = null; Console.WriteLine($"{a ?? 0}"); // a가 null이면 ?? 뒤의 값이 출력 a = 100; Console.WriteLine($"{a ?? 0}"); }
/// <summary> /// Base64解密 /// </summary> /// <param name="text">要解密的字符串</param> public static string DecodeBase64(string inputText) { var text = inputText; //如果字符串为空,则返回 if (string.IsNullOrEmpty(text)) { return(""); } //将空格替换为加号 text = text.Replace(" ", "+"); try { if ((text.Length % 4) != 0) { return("包含不正确的BASE64编码"); } if (!Regex.IsMatch(text, "^[A-Z0-9/+=]*$", RegexOptions.IgnoreCase)) { return("包含不正确的BASE64编码"); } string Base64Code = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="; int page = text.Length / 4; ArrayList outMessage = new ArrayList(page * 3); char[] message = text.ToCharArray(); for (int i = 0; i < page; i++) { byte[] instr = new byte[4]; instr[0] = (byte)Base64Code.IndexOf(message[i * 4]); instr[1] = (byte)Base64Code.IndexOf(message[i * 4 + 1]); instr[2] = (byte)Base64Code.IndexOf(message[i * 4 + 2]); instr[3] = (byte)Base64Code.IndexOf(message[i * 4 + 3]); byte[] outstr = new byte[3]; outstr[0] = (byte)((instr[0] << 2) ^ ((instr[1] & 0x30) >> 4)); if (instr[2] != 64) { outstr[1] = (byte)((instr[1] << 4) ^ ((instr[2] & 0x3c) >> 2)); } else { outstr[2] = 0; } if (instr[3] != 64) { outstr[2] = (byte)((instr[2] << 6) ^ instr[3]); } else { outstr[2] = 0; } outMessage.Add(outstr[0]); if (outstr[1] != 0) { outMessage.Add(outstr[1]); } if (outstr[2] != 0) { outMessage.Add(outstr[2]); } } byte[] outbyte = (byte[])outMessage.ToArray(Type.GetType("System.Byte")); return(Encoding.UTF8.GetString(outbyte)); } catch (Exception ex) { Logging.Log4NetHelper.Error(typeof(SecurityUtil), ex); throw; } }
/// <summary> /// Base64加密 /// </summary> /// <param name="text">要加密的字符串</param> /// <returns></returns> public static string EncodeBase64(string text) { //如果字符串为空,则返回 if (string.IsNullOrEmpty(text)) { return(""); } try { char[] Base64Code = new char[] { 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '+', '/', '=' }; byte empty = (byte)0; ArrayList byteMessage = new ArrayList(Encoding.Default.GetBytes(text)); StringBuilder outmessage; int messageLen = byteMessage.Count; int page = messageLen / 3; int use = 0; use = messageLen % 3; if (use > 0) { for (int i = 0; i < 3 - use; i++) { byteMessage.Add(empty); } page++; } outmessage = new System.Text.StringBuilder(page * 4); for (int i = 0; i < page; i++) { byte[] instr = new byte[3]; instr[0] = (byte)byteMessage[i * 3]; instr[1] = (byte)byteMessage[i * 3 + 1]; instr[2] = (byte)byteMessage[i * 3 + 2]; int[] outstr = new int[4]; outstr[0] = instr[0] >> 2; outstr[1] = ((instr[0] & 0x03) << 4) ^ (instr[1] >> 4); if (!instr[1].Equals(empty)) { outstr[2] = ((instr[1] & 0x0f) << 2) ^ (instr[2] >> 6); } else { outstr[2] = 64; } if (!instr[2].Equals(empty)) { outstr[3] = (instr[2] & 0x3f); } else { outstr[3] = 64; } outmessage.Append(Base64Code[outstr[0]]); outmessage.Append(Base64Code[outstr[1]]); outmessage.Append(Base64Code[outstr[2]]); outmessage.Append(Base64Code[outstr[3]]); } return(outmessage.ToString()); } catch (Exception ex) { Logging.Log4NetHelper.Error(typeof(SecurityUtil), ex); throw; } }
protected IEnumerable GetFileSystemEntryItems(List <FileSystemInfo> directoriesAndFiles) { if (directoriesAndFiles == null || !directoriesAndFiles.Any()) { return(new ArrayList(0)); } int numberOfItems = directoriesAndFiles.Count; if (GroupFoldersAndFiles) { numberOfItems = numberOfItems + 2; } ArrayList items = new ArrayList(numberOfItems); for (int i = 0; i < directoriesAndFiles.Count; i++) { FileSystemInfo item = directoriesAndFiles[i]; if (item is DirectoryInfo directoryInfo) { if (GroupFoldersAndFiles && i == 0) { items.Add(new FileSystemEntriesGroupHeader() { Header = Localization.Strings.Folders, ShowSeparator = false }); } bool isSelected = directoryInfo.FullName == m_controller.CurrentDirectory?.FullName; items.Add(new DirectoryInfoItem() { IsSelected = isSelected, Value = directoryInfo }); } else if (item is FileInfo fileInfo) { if (GroupFoldersAndFiles) { if (i == 0) { items.Add(new FileSystemEntriesGroupHeader() { Header = Localization.Strings.Files, ShowSeparator = false }); } else if (directoriesAndFiles[i - 1] is DirectoryInfo) { items.Add(new FileSystemEntriesGroupHeader() { Header = Localization.Strings.Files, ShowSeparator = true }); } } bool isSelected = fileInfo.FullName == m_controller.CurrentFileFullName; items.Add(new FileInfoItem() { IsSelected = isSelected, Value = fileInfo }); } } return(items); }
public void AddPlayer(Soil p) { playerList.Add(p); }
public Hashtable ArraySort2by2(Hashtable sourcehash, double columnidx, Boolean mode) { //Hash Table의 크기에 맞춰 컬럼생성 DataTable dt = new DataTable(); Hashtable samplerow= ((Hashtable)sourcehash[1.0]); int columnsize = samplerow.Count; for (int i = 0; i < columnsize; i++) { Type columntype=samplerow[Convert.ToDouble(i+1)].GetType(); dt.Columns.Add("col" + (i + 1).ToString(),columntype); } //데이터 테이블로 넣는다. foreach (var key in sourcehash.Keys) { Hashtable hs2 = (Hashtable)sourcehash[key]; ArrayList ar = new ArrayList(); for (double i=1.0; i <= hs2.Keys.Count;i=i+1 ) { //ar[columnkey]=hs2[columnkey].ToString(); ar.Add(hs2[i]); } //foreach (var columnkey in hs2.Keys) //{ // //ar[columnkey]=hs2[columnkey].ToString(); // ar.Add(hs2[columnkey]); //} dt.Rows.Add(ar.ToArray()); //Hashtable hhs2=(Hashtable)hs[h1]; //foreach(int h2 in hhs2.Keys) //{ Console.WriteLine(dt); //} } int idx = Convert.ToInt32(columnidx); dt.DefaultView.Sort = "col"+idx.ToString() + " ASC"; dt = dt.DefaultView.ToTable(false); Hashtable resultHs = new Hashtable(); //Datatable -> HashTable for (int i = 1; i < dt.Rows.Count + 1; i++) { Hashtable resultsubHs = new Hashtable(); for (int j = 1; j < dt.Columns.Count + 1; j++) { resultsubHs.Add((double)j, dt.Rows[i-1][j - 1]); } resultHs.Add((double)i, resultsubHs); } Console.WriteLine(resultHs); return resultHs; }
public Hashtable SubGroupingbyColumn(Hashtable sourcehash, double keyColIdx) { //Hash Table의 크기에 맞춰 컬럼생성 DataTable dt = new DataTable(); Hashtable samplerow = ((Hashtable)sourcehash[1.0]); int columnsize = samplerow.Count; for (int i = 0; i < columnsize; i++) { Type columntype = samplerow[Convert.ToDouble(i + 1)].GetType(); dt.Columns.Add("col" + (i + 1).ToString(), columntype); } //데이터 테이블로 넣는다. foreach (double key in sourcehash.Keys.Cast<double>().OrderBy(T=>T)) { Hashtable hs2 = (Hashtable)sourcehash[key]; ArrayList ar = new ArrayList(); foreach (var columnkey in hs2.Keys.Cast<double>().OrderBy(T => T)) { //ar[columnkey]=hs2[columnkey].ToString(); ar.Add(hs2[columnkey]); } dt.Rows.Add(ar.ToArray()); Console.WriteLine(dt); } //int idx = Convert.ToInt32(columnidx); //dt.DefaultView.Sort = "col" + idx.ToString() + " ASC"; dt = dt.DefaultView.ToTable(false); var groupset=dt.AsEnumerable().GroupBy(r => r[Convert.ToInt32(keyColIdx)]).Select(g => g); Hashtable resultHs = new Hashtable(); //Datatable -> HashTable var resultlist=groupset.ToList(); for (int i = 1; i <= resultlist.Count ; i++) { Hashtable resultsubHs = new Hashtable(); resultsubHs.Add(1.0,resultlist[i-1].Key); var resultlist2 = resultlist[i - 1].ToArray(); for (int j =1; j <= resultlist2.Count() ; j++) { Hashtable resultsub2Hs = new Hashtable(); for (int k = 1; k < resultlist2[j-1].ItemArray.Count()+1; k++) { resultsub2Hs.Add((double)k, resultlist2[j-1][k-1]); } resultsubHs.Add((double)j+1, resultsub2Hs); } resultHs.Add((double)i, resultsubHs); } Console.WriteLine(resultHs); return resultHs; }
public ArrayList alys(string content) { string partTorrentUrl = findKey(content); ArrayList list = new ArrayList(); if (content.Contains("Sorry, but you are looking for something that isn't here.")) { Console.WriteLine(" NOT FOUND"); return(list); } string[] content1 = content.Split(new string[] { "<div class=\"image\">" }, StringSplitOptions.RemoveEmptyEntries); for (int i = 0; i < content1.Length; i++) { if (content1[i].Contains("OLink('&#") || content1[i].Contains("OLink(&#")) { His his = new His(); his.OriginalHtml = content1[i]; string s = content1[i].Split(new string[] { "<script>document.write(jj(\"", "\"))</script>" }, StringSplitOptions.RemoveEmptyEntries)[1]; string res = "";//engine.CallGlobalFunction<string>("jj", s); res = res.Replace(">", "/>"); MatchCollection mc = r1.Matches(res); foreach (Match m in mc) { XmlDocument xmlDoc = new XmlDocument(); xmlDoc.LoadXml(m.ToString()); string key = xmlDoc.GetElementsByTagName("img")[0].Attributes["style"].Value; key = key.Substring(0, key.IndexOf(";")); string cha = dictionary[key]; res = res.Replace(m.ToString(), cha); } his.Info = res; try { try { his.Vid = r2.Matches(res)[0].ToString().Split(new string[] { "Vídeo Id: ", "<br/>" }, StringSplitOptions.RemoveEmptyEntries)[0]; } catch (Exception e) { Console.WriteLine("VID NOT FOUND!!"); Console.WriteLine(e.Message); } string size = res.Split(new string[] { "<br/>Sìze: ", "<br/><u/>" }, StringSplitOptions.RemoveEmptyEntries)[1]; if (size.EndsWith("GB")) { size = size.Replace("Size:", "").Replace("GB", ""); his.Size = Convert.ToDouble(size) * 1024; } else { his.Size = Convert.ToDouble(size.Replace("MB", "").Replace("KB", "")); } his.Actress = res.Split(new string[] { "<br/>" }, StringSplitOptions.RemoveEmptyEntries)[0]; his.FileCount = Convert.ToInt32(res.Split(new string[] { "Fíles in tørrent:</u/>", "fìles<br/>" }, StringSplitOptions.RemoveEmptyEntries)[1]); try { his.Files = res.Split(new string[] { "fìles<br/>" }, StringSplitOptions.RemoveEmptyEntries)[1]; } catch { Console.WriteLine("NO FILE LIST"); } his.Html = getImg(his, partTorrentUrl); } catch (Exception e) { Console.WriteLine(e.StackTrace); Console.WriteLine(res); } list.Add(his); } } return(list); }
public static bool InsertPurchaseOrder(PurchaseOrderModel PurchaseOrderM, List<PurchaseOrderDetailModel> PurchaseOrderDetailMList, out int IndexIDentity, out string Reason, Hashtable htExtAttr) { try { IndexIDentity = 0; //判断引用源单数量有没有超过,超过了就不让保存 if (!PurchaseOrderDBHelper.CanSave(PurchaseOrderDetailMList, out Reason)) return false; ArrayList lstAdd = new ArrayList(); //插入主表 SqlCommand AddPri = PurchaseOrderDBHelper.InsertPurchaseOrder(PurchaseOrderM); lstAdd.Add(AddPri); string OrderNo = PurchaseOrderM.OrderNo; //插入明细 foreach (PurchaseOrderDetailModel PurchaseOrderDetailM in PurchaseOrderDetailMList) { SqlCommand AddDetail = PurchaseOrderDBHelper.InsertPurchaseOrderDetail(PurchaseOrderDetailM, OrderNo); lstAdd.Add(AddDetail); } #region 拓展属性 SqlCommand cmd = new SqlCommand(); GetExtAttrCmd(PurchaseOrderM, htExtAttr, cmd); if (htExtAttr.Count > 0) lstAdd.Add(cmd); #endregion //获取登陆用户信息 UserInfoUtil userInfo = (UserInfoUtil)SessionUtil.Session["UserInfo"]; //定义返回变量 bool isSucc = false; /* * 定义日志内容变量 * 增删改相关的日志,需要输出操作日志,该类型日志插入到数据库 * 其他的 如出现异常时,需要输出系统日志,该类型日志保存到日志文件 */ //执行插入操作 try { isSucc = SqlHelper.ExecuteTransWithArrayList(lstAdd); } catch (Exception ex) { //输出日志 WriteSystemLog(userInfo, ex); } //定义变量 string remark; //成功时 if (isSucc) { //设置操作成功标识 remark = ConstUtil.LOG_PROCESS_SUCCESS; IndexIDentity = int.Parse(((SqlCommand)AddPri).Parameters["@IndexID"].Value.ToString()); } else { //设置操作成功标识 remark = ConstUtil.LOG_PROCESS_FAILED; IndexIDentity = 0; } LogInfoModel logModel = InitLogInfo(OrderNo); //涉及关键元素 这个需要根据每个页面具体设置,本页面暂时设置为空 logModel.Element = ConstUtil.LOG_PROCESS_INSERT; //设置操作成功标识 logModel.Remark = remark; //登陆日志 LogDBHelper.InsertLog(logModel); return isSucc; } catch (Exception ex) { throw ex; } }
static void Main(string[] args) { Console.WriteLine("Hello World!"); WriteLine("Hello World!"); // 숫자에서 _는 무시된다 int e = -10_000_000; uint f = 300_000_000; // Format에서 $는 {}를 변수로 받게 해준다 WriteLine($"e={e}, f={f}"); // 없으면 인자 순서번호로 사용 WriteLine("e={0}, f={1}", e, f); float a = 3.1415_9265_7932_3846_2643_3832_79f; // 6자리 double b = 3.1415_9265_7932_3846_2643_3832_79; // 14자리 decimal c = 3.1415_9265_7932_3846_2643_3832_79m; // 끝까지 WriteLine(a); WriteLine(b); WriteLine(c); WriteLine(); WriteLine(); string a1 = "독도는 우리땅"; string b1 = "대마도도 우리땅"; WriteLine(a1); WriteLine(b1); object a2 = 123; object b2 = 3.14159m; object c2 = true; object d2 = "문자열"; WriteLine(a2); WriteLine(b2); WriteLine(c2); WriteLine(d2); int a3 = 123; string b3 = a3.ToString(); WriteLine(b3); float c3 = 3.14f; string d3 = c3.ToString(); WriteLine(d3); string e3 = "123456"; int f3 = int.Parse(e3); WriteLine(f3); string g3 = "1.2345"; float h3 = float.Parse(g3); WriteLine(h3); WriteLine(); WriteLine(); const int MAX_INT = 2147483647; const int MIN_INT = -2147483648; WriteLine((int)COLOR_CODE.RED); WriteLine((int)COLOR_CODE.BLUE); WriteLine(COLOR_CODE.GREEN); WriteLine(COLOR_CODE.ORANGE); COLOR_CODE code = COLOR_CODE.RED; WriteLine(code == COLOR_CODE.BLUE); WriteLine(code == COLOR_CODE.RED); WriteLine((int)COLOR_CODE.GREEN); WriteLine(value: (int)COLOR_CODE.ORANGE); WriteLine(); WriteLine(); int?a4 = null; WriteLine(a4.HasValue); WriteLine(a4 != null); a4 = 3; WriteLine(a4.HasValue); WriteLine(a4 != null); WriteLine(a4.Value); WriteLine(a4); var a5 = 20; WriteLine("Typr: {0}, Value: {1}", a5.GetType(), a5); var b5 = 3.141592; WriteLine("Typr: {0}, Value: {1}", b5.GetType(), b5); var c5 = "Hello World"; WriteLine("Typr: {0}, Value: {1}", c5.GetType(), c5); var d5 = new int[] { 10, 20, 30 }; Write("Typr: {0}, Value: ", d5.GetType()); foreach (var e5 in d5) { Write("{0} ", e5); } WriteLine(); string str = "This is string sample"; WriteLine(); WriteLine(str); WriteLine(); WriteLine("Index of 'search' : {0}", str.IndexOf("search")); WriteLine("Index of 'h' : {0}", str.IndexOf('h')); WriteLine("StartWith 'This' : {0}", str.StartsWith("This")); WriteLine("StartWith 'string' : {0}", str.StartsWith("string")); WriteLine("EndWith 'This' : {0}", str.EndsWith("This")); WriteLine("EndWith 'sample' : {0}", str.EndsWith("sample")); WriteLine("Contains 'search' : {0}", str.EndsWith("search")); WriteLine("Contains 'school' : {0}", str.EndsWith("school")); WriteLine("Replace 'sample' with 'example' : {0}", str.Replace("sample", "example")); WriteLine("ToLower() : {0}", "Hello World".ToLower()); WriteLine("ToUpper() : {0}", "Hello World".ToUpper()); WriteLine("Insert() : {0}", "Hello World".Insert(6, "Wonderful ")); WriteLine("Remove() : {0}", "Hello Wonderful World".Remove(6, 10)); WriteLine("Trim() : {0}", " I am Tom ".Trim()); WriteLine("TrimStart() : {0}", " I am Tom ".TrimStart()); WriteLine("TrimEnd() : {0}", " I am Tom ".TrimEnd()); string str2 = "Welcome to the C# world"; WriteLine(str2.Substring(15, 2)); WriteLine(str2.Substring(8)); WriteLine(); string[] arr = str2.Split(new string[] { " " }, StringSplitOptions.RemoveEmptyEntries); WriteLine("Word Count : {0}", arr.Length); foreach (string element in arr) { WriteLine("{0}", element); } string fmt = "{0,-10}{1,-5}{2,10}"; WriteLine(fmt, "Type", "Size", "Explain"); WriteLine(fmt, "byte", "1", "byte타입"); WriteLine(fmt, "short", "2", "short타입"); WriteLine(fmt, "int", "4", "int타입"); WriteLine(fmt, "long", "8", "long타입"); WriteLine("10진수: {0:D}", 123); WriteLine("10진수: {0:D5}", 123); WriteLine("16진수: {0:X}", 0xFF1234); WriteLine("16진수: {0:X8}", 0xFF1234); WriteLine("숫자: {0:N}", 123456); WriteLine("숫자: {0:N0}", 123456); WriteLine("고정소수점: {0:F}", 123.456); WriteLine("고정소수점: {0:F5}", 123.456); WriteLine("공학: {0:E}", 123.456789); DateTime dt = DateTime.Now; WriteLine("12시간 형식: {0:yyyy-MM-dd tt hh:mm:ss (ddd)}", dt); WriteLine("24시간 형식: {0:yyyy-MM-dd HH:mm:ss (dddd)}", dt); CultureInfo ciKR = new CultureInfo("ko-KR"); WriteLine(); WriteLine(dt.ToString("yyyy-MM-dd tt hh:mm:ss (ddd)", ciKR)); WriteLine(dt.ToString("yyyy-MM-dd HH:mm:ss (dddd)", ciKR)); WriteLine(dt.ToString(ciKR)); CultureInfo ciUS = new CultureInfo("en-US"); WriteLine(); WriteLine(dt.ToString("yyyy-MM-dd tt hh:mm:ss (ddd)", ciUS)); WriteLine(dt.ToString("yyyy-MM-dd HH:mm:ss (dddd)", ciUS)); WriteLine(dt.ToString(ciUS)); string name = "홍길동"; int age = 25; WriteLine($"{name,-10}, {age:D3}"); name = "김유신"; age = 30; WriteLine($"{name}, {age,-10:D3}"); name = "박문수"; age = 15; WriteLine($"{name}, {(age > 20 ? "성인" : "미성년자")}"); ArrayList arrList = null; arrList?.Add("C++"); arrList?.Add("C#"); WriteLine($"Count : {arrList?.Count}"); WriteLine($"{arrList?[0]}"); WriteLine($"{arrList?[1]}"); arrList = new ArrayList(); arrList?.Add("C++"); arrList?.Add("C#"); WriteLine($"Count : {arrList?.Count}"); WriteLine($"{arrList?[0]}"); WriteLine($"{arrList?[1]}"); int?num = null; WriteLine($"{num ?? 0}"); num = 10; WriteLine($"{num ?? 0}"); string str3 = null; WriteLine($"{str3 ?? "Default"}"); str3 = "I study C#"; WriteLine($"{str3 ?? "Default"}"); Write("요일을 입력하세요 (월화수목금토) :"); string day = ReadLine(); switch (day) { case "일": WriteLine("Sunday"); break; case "월": WriteLine("Monday"); break; case "화": WriteLine("Tuesday"); break; case "수": WriteLine("Wednesday"); break; case "목": WriteLine("Thurday"); break; case "금": WriteLine("Friday"); break; case "토": WriteLine("Saturday"); break; default: WriteLine("요일이 아니라구"); break; } object obj = null; string str4 = ReadLine(); if (int.TryParse(str4, out int int_num)) { obj = int_num; } else if (float.TryParse(str4, out float float_num)) { obj = float_num; } else { obj = str4; } switch (obj) { case int i_obj: WriteLine($"{i_obj}는 int 형식"); break; case float f_obj: WriteLine($"{f_obj}는 float 형식"); break; default: WriteLine($"{obj}는 object 형식"); break; } int[] arr2 = new int[] { 0, 1, 2, 3, 4 }; foreach (int i in arr2) { WriteLine(i); } int result = Calculator.Plus(2, 5); WriteLine(result); result = Calculator.Minus(10, 4); WriteLine(result); int x = 3; int y = 5; WriteLine($"x:{x}, y:{y}"); Swap(ref x, ref y); WriteLine($"x:{x}, y:{y}"); Product carrot = new Product(); ref int ref_price = ref carrot.GetPrice();
/** * 获取html节点的所有属性 * @return * */ public static Hashtable GetAttributes(string htmlnode) { //先去掉等号两边的空格 htmlnode = Regex.Replace(htmlnode, @"\s*=\s*", "=", RegexOptions.Singleline); Hashtable result = new Hashtable(); ArrayList atts = new ArrayList(); MatchCollection matches = Regex.Matches(htmlnode, @"\s[\w\-:]+=", RegexOptions.IgnoreCase | RegexOptions.Singleline); foreach (Match m in matches) { string val = m.Groups[0].Value; atts.Add(val); } if (atts.Count == 0) { return(result); } for (int j = 0; j < atts.Count; j++) { string name = ((string)atts[j]).Replace("=", ""); name = name.Trim(); name = name.ToLower(); int pos = htmlnode.IndexOf((string)atts[j]) + ((string)atts[j]).Length; string ch = htmlnode.Substring(pos, 1); string symbol = null; string f = ""; while (ch != symbol && pos < htmlnode.Length) { if (symbol == null) { if (ch == "\"" || ch == "'") { symbol = ch; } else if (symbol != "\"" && symbol != "'") { symbol = " "; f += ch; } } else { f += ch; } ch = htmlnode.Substring(++pos, 1); if (symbol == " " && ch == ">") { break; } } result[name] = f.Trim(); } return(result); }
public static void AddProduct(User user) { users.Add(user); }
public void addToBack(Object n) { linkedList.Add(n); }
static void day1() { Console.WriteLine("Hello World!"); WriteLine("안녕 세상!"); sbyte a = -10; byte b = 40; WriteLine($"a={a}, b ={b}"); short c = -30000; ushort d = 60000; WriteLine("c={0}, d={1}", c, d); int e = -10_000_000; uint f = 300_000_000; WriteLine($"e={e}, f={f}"); long g = -500_000_000_000; ulong h = 2_000_000_000_000_000_000; WriteLine("g={0}, h={1}", g, h); // decibal 16(29자리까지 표현) float f_a = 3.1415_9265_3589_7932_3846_4643_3832_79f; double d_a = 3.1415_9265_3589_7932_3846_4643_3832_79; decimal dec_a = 3.1415_9265_3589_7932_3846_4643_3832_79m; WriteLine(f_a); WriteLine(d_a); WriteLine(dec_a); string strA = "동해물과 백두산이"; string strB = "마르고 닳도록"; WriteLine(strA); WriteLine(strB); object ob_a = 123; object ob_b = 3.14159m; object ob_c = true; object ob_d = "문자열"; WriteLine(ob_a); WriteLine(ob_b); WriteLine(ob_c); WriteLine(ob_d); int i_a = 123; string str_a = i_a.ToString(); WriteLine(str_a); float f_b = 3.14f; string str_b = f_b.ToString(); WriteLine(str_b); string str = "123456"; int i_c = int.Parse(str); WriteLine(i_c); const int MAX_INT = 2147483647; const int MIN_INT = -2147483648; WriteLine(MAX_INT); WriteLine(MIN_INT); WriteLine((int)ColorCode.RED); WriteLine((int)ColorCode.BLUE); WriteLine(ColorCode.GREEN); WriteLine(ColorCode.ORANGE); ColorCode cCode = ColorCode.RED; WriteLine(cCode == ColorCode.BLUE); WriteLine(cCode == ColorCode.RED); WriteLine((int)ColorCode2.RED); WriteLine((int)ColorCode2.BLUE); WriteLine((int)ColorCode2.GREEN); WriteLine((int)ColorCode2.ORANGE); int?m = null; //nullable 연산자 '?' WriteLine(m.HasValue); WriteLine(m != null); m = 3; WriteLine(m.HasValue); WriteLine(m != null); WriteLine(m.Value); WriteLine(m); // var 타입 // 선언과 동시에 초기화 필요 run때 bind됨 // 로컬 변수로만 사용 가능 var var_a = 20; WriteLine("Typr:{0}, value:{1}", var_a.GetType(), var_a); var var_b = 3.141592; WriteLine("typr:{0}, value:{1}", var_b.GetType(), var_b); var var_c = "hello world"; WriteLine("typr:{0}, value:{1}", var_c.GetType(), var_c); var var_d = new int[] { 10, 20, 30 }; WriteLine("typr:{0}, value:", var_d.GetType()); foreach (var var_e in var_d) { Write("{0} ", var_e); } WriteLine(); string st = "This is string search sample"; WriteLine(st); WriteLine("index of 'search' : {0}", st.IndexOf("search")); WriteLine("index of 'h' : {0}", st.IndexOf('h')); WriteLine("StartWith 'This' : {0}", st.StartsWith("This")); WriteLine("StartWith 'string : {0}", st.StartsWith("string")); WriteLine("EndsWith 'This' : {0}", st.EndsWith("This")); WriteLine("EndsWith 'sample' : {0}", st.EndsWith("sample")); WriteLine("Contains 'search' : {0}", st.Contains("search")); WriteLine("Contains 'school' : {0}", st.Contains("school")); WriteLine("Replace 'sample' with 'example : {0}", st.Replace("sample", "example")); WriteLine("ToLower() : {0}", "Hello World".ToLower()); WriteLine("ToUpper() : {0}", "Hello World".ToUpper()); WriteLine("Insert() : {0}", "Hello World".Insert(6, "Wonderful")); WriteLine("Remove() : {0}", "Hello Wonderful World".Remove(6, 10)); WriteLine("Trim() : '{0}'", " I am Tom ".Trim()); WriteLine("TrimeStart() : '{0}'", " I am Tom ".TrimStart()); WriteLine("TrimEnd() : '{0}'", " I am Tom ".TrimEnd()); string strr = "Welcom to the C# World!"; WriteLine(strr.Substring(15, 2)); WriteLine(strr.Substring(8)); string[] arr = strr.Split(new string[] { " " }, StringSplitOptions.RemoveEmptyEntries); // 빈 항목은 제거 " " WriteLine("word count : {0}", arr.Length); foreach (string element in arr) { WriteLine("{0} ", element); } string fmt = "{0,-10}{1,-5}{2,20}"; WriteLine(fmt, "Type", "Size", "Explain"); WriteLine(fmt, "byte", "1", "byte 타입"); WriteLine(fmt, "short", "2", "short 타입"); WriteLine(fmt, "int", "4", "int 타입"); WriteLine(fmt, "long", "8", "long 타입"); WriteLine("10진수: {0:D}", 123); WriteLine("10진수: {0:D3}", 123); WriteLine("16진수 : 0x{0:X}", 0xFF1234); WriteLine("16진수 : 0x{0:X8}", 0xFF1234); WriteLine("숫자 : {0:N}", 123456); WriteLine("숫자 : {0:N0}", 123456); WriteLine("고정소수점 : {0:F}", 123.456); WriteLine("고정소수점 : {0:F5}", 123.456); WriteLine("공학: {0:E}", 123.456789); DateTime dt = DateTime.Now; WriteLine("12시간 형식 : {0:yyyy-MM-dd tt hh:mm:ss (ddd)}", dt); WriteLine("24시간 형식 : {0:yyyy-MM-dd HH:mm:ss (dddd)}", dt); CultureInfo ciKR = new CultureInfo("ko-KR"); WriteLine(); WriteLine(dt.ToString("yyyy-MM-dd tt hh:mm:ss (ddd)"), ciKR); WriteLine(dt.ToString("yyyy-MM-dd HH:mm:ss (dddd)"), ciKR); WriteLine(dt.ToString(ciKR)); CultureInfo ciUS = new CultureInfo("en-US"); WriteLine(); WriteLine(dt.ToString("yyyy-MM-dd tt hh:mm:ss (ddd)"), ciUS); WriteLine(dt.ToString("yyyy-MM-dd HH:mm:ss (dddd)"), ciUS); WriteLine(dt.ToString(ciUS)); string name = "고길동"; int age = 25; WriteLine($"{name,-10}, {age:D3}"); name = "김유신"; age = 30; WriteLine($"{name},{age,-10:D3}"); name = "박문수"; age = 15; WriteLine($"{name},{(age > 20 ? "성인" : "미성년자")}"); ArrayList arA = null; arA?.Add("C++"); // 앞에거가 null인지 판단. null일 경우 null반환. 아니면 뒤에꺼 실행 arA?.Add("C#"); WriteLine($"Count : {arA?.Count}"); WriteLine($"{arA?[0]}"); WriteLine($"{arA?[1]}"); arA = new ArrayList(); arA?.Add("C++"); arA?.Add("C#"); WriteLine($"Count : {arA?.Count}"); WriteLine($"{arA?[0]}"); WriteLine($"{arA?[1]}"); int?num = null; WriteLine($"{num ?? 0}"); // null이면 뒤쪽꺼, 아니면 원래 쓰려고했던거. 널 병합 연산자 num = 10; WriteLine($"{num ?? 0}"); string strN = null; WriteLine($"{strN ?? "Default"}"); strN = "I study C#"; WriteLine($"{strN ?? "Default"}"); Write("요일을 입력하세요 (월 화 수 목 금 토 일) : "); string day = ReadLine(); switch (day) { case "일": WriteLine("Sunday"); break; case "월": WriteLine("Monday"); break; case "화": WriteLine("Tuesday"); break; case "수": WriteLine("Wednesday"); break; case "목": WriteLine("Thursday"); break; case "금": WriteLine("Friday"); break; case "토": WriteLine("Saturday"); break; } object obj = null; // tryparse : 제대로 변경되면 true 안되면 false; parse는 try catch로 잡아줘야함. 정상적인 변환이 아니면 터짐 string str1 = ReadLine(); if (int.TryParse(str1, out int int_num)) { obj = int_num; } else if (float.TryParse(str1, out float float_num)) { obj = float_num; } else { obj = str1; } switch (obj) { case int i: WriteLine($"{i}는 int 형식입니다"); break; case float ft: WriteLine($"{ft}는 float 형식입니다"); break; default: WriteLine($"{obj}는 object 형식입니다"); break; } int[] arr1 = new int[] { 0, 1, 2, 3, 4 }; foreach (int i in arr1) { WriteLine(i); } WriteLine("{0} + {1} = {2}", 7, 8, Calculator.Plus(7, 8)); int x = 3; int y = 5; WriteLine($"x:{x} , y:{y}"); Calculator.Swap(ref x, ref y); WriteLine($"x:{x} , y:{y}"); Product carrot = new Product(); ref int ref_price = ref carrot.getPrice();
private bool LexFileArguments(string fileName, out string[] arguments) { string args = null; try { using (FileStream file = new FileStream(fileName, FileMode.Open, FileAccess.Read)) { args = (new StreamReader(file)).ReadToEnd(); } } catch (Exception e) { this.reporter(string.Format("Error: Can't open command line argument file '{0}' : '{1}'", fileName, e.Message)); arguments = null; return(false); } bool hadError = false; ArrayList argArray = new ArrayList(); StringBuilder currentArg = new StringBuilder(); bool inQuotes = false; int index = 0; // while (index < args.Length) try { while (true) { // skip whitespace while (char.IsWhiteSpace(args[index])) { index += 1; } // # - comment to end of line if (args[index] == '#') { index += 1; while (args[index] != '\n') { index += 1; } continue; } // do one argument do { if (args[index] == '\\') { int cSlashes = 1; index += 1; while (index == args.Length && args[index] == '\\') { cSlashes += 1; } if (index == args.Length || args[index] != '"') { currentArg.Append('\\', cSlashes); } else { currentArg.Append('\\', (cSlashes >> 1)); if (0 != (cSlashes & 1)) { currentArg.Append('"'); } else { inQuotes = !inQuotes; } } } else if (args[index] == '"') { inQuotes = !inQuotes; index += 1; } else { currentArg.Append(args[index]); index += 1; } } while (!char.IsWhiteSpace(args[index]) || inQuotes); argArray.Add(currentArg.ToString()); currentArg.Length = 0; } } catch (System.IndexOutOfRangeException) { // got EOF if (inQuotes) { this.reporter(string.Format("Error: Unbalanced '\"' in command line argument file '{0}'", fileName)); hadError = true; } else if (currentArg.Length > 0) { // valid argument can be terminated by EOF argArray.Add(currentArg.ToString()); } } arguments = (string[])argArray.ToArray(typeof(string)); return(hadError); }
// Update is called once per frame void Update() { float currentTime = Time.time; float timeElapsed = currentTime - startTime; accuracy = Mathf.RoundToInt((float)currentWaypointIndex / (float)numWaypoints * 100); if (!isGameOver && (timeElapsed >= timeLimit)) { isGameOver = true; endTime = Time.time; timedOut = true; } if (!isGameOver) { //If left mouse button is clicked if (Input.GetMouseButton(0)) { //Get mouse position in screen space Vector3 mousePos = new Vector3(Input.mousePosition.x, Input.mousePosition.y, 4.9f); //Get mouse position in world space Vector3 mouseWorldPos = player.GetComponent <Player>().playerCamera.GetComponent <Camera>().ScreenToWorldPoint(mousePos); if (distance(mouseWorldPos, waypoints[currentWaypointIndex].transform.position) < 0.25) { color_progress[currentWaypointIndex]++; currentWaypointIndex++; if (currentWaypointIndex >= numWaypoints) { isGameOver = true; endTime = Time.time; } } for (int k = 0; k < numWaypoints; k++) { if (color_progress[k] > 0 && color_progress[k] < 25) { waypoints[k].GetComponent <Renderer>().material.SetColor("_Color", Color.Lerp(starting_colors[k], Color.magenta, color_progress[k] / 25.0f)); color_progress[k]++; } } GameObject trace = Instantiate(traceAsset, mouseWorldPos, traceAsset.transform.rotation); trace.GetComponent <Renderer>().material.SetColor("_Color", Color.cyan); trace.transform.localScale = new Vector2(0.3f, 0.3f); traceList.Add(trace); if (previousCursor != null) { Destroy(previousCursor); } cursor = Instantiate(cursorAsset, mouseWorldPos, cursorAsset.transform.rotation); cursor.GetComponent <Renderer>().material.SetColor("_Color", Color.cyan); cursor.transform.localScale = new Vector2(1.2f, 1.2f); previousCursor = cursor; } } else { if (!timedOut) { for (int k = 0; k < numWaypoints; k++) { waypoints[k].GetComponent <Renderer>().material.SetColor("_Color", Color.magenta); } } if (currentTime - endTime > 3) { //Debug.Log("ACCURACY: " + accuracy + "%"); Destroy(cursor); for (int p = 0; p < numWaypoints; p++) { Destroy(waypoints[p]); } for (int q = 0; q < traceList.Count; q++) { Destroy((GameObject)traceList[q]); } player.GetComponent <Player>().status.accuracy = accuracy; Aimer aimer = Instantiate(Resources.Load("Aimer") as GameObject).GetComponent <Aimer>(); aimer.cam = player.GetComponent <Player>().playerCamera.GetComponent <Camera>(); aimer.spell = spell; aimer.gameMaster = gameMaster; aimer.player = player.GetComponent <Player>(); aimer.targetList = player.GetComponent <TargetList>(); player.GetComponent <TargetList>().CmdClear(); aimer.startFollowing = true; // gameMaster.spellButtonsEnabled = true; Destroy(gameObject); } } }
private static void intersectLists(ArrayList A, ArrayList B, ArrayList result) { // The optimization is done according to the following truth // (A|B|C) intersect (B|C|E|D)) == B|C|(A inter E)|(A inter D) // // We also check on any duplicates in the result bool[] aDone = new bool[A.Count]; //used to avoid duplicates in result bool[] bDone = new bool[B.Count]; int ia = 0; int ib = 0; // Round 1st // Getting rid of same permissons in the input arrays (assuming X /\ X = X) foreach (EndpointPermission a in A) { ib = 0; foreach (EndpointPermission b in B) { // check to see if b is in the result already if (!bDone[ib]) { //if both elements are the same, copy it into result if (a.Equals(b)) { result.Add(a); aDone[ia] = bDone[ib] = true; //since permissions are ORed we can break and go to the next A break; } } ++ib; } //foreach b in B ++ia; } //foreach a in A ia = 0; // Round second // Grab only intersections of objects not found in both A and B foreach (EndpointPermission a in A) { if (!aDone[ia]) { ib = 0; foreach (EndpointPermission b in B) { if (!bDone[ib]) { EndpointPermission intesection = a.Intersect(b); if (intesection != null) { bool found = false; // check to see if we already have the same result foreach (EndpointPermission res in result) { if (res.Equals(intesection)) { found = true; break; } } if (!found) { result.Add(intesection); } } } //!Done[ib] ++ib; } //foreach b in B } //!Done[ia] ++ia; } //foreach a in A }
private static void ParseAddXmlElement(SecurityElement et, ArrayList listToAdd, string accessStr) { foreach (SecurityElement uriElem in et.Children) { if (uriElem.Tag.Equals("ENDPOINT")) { Hashtable attributes = uriElem.Attributes; string tmpStr; try { tmpStr = attributes["host"] as string; } catch { tmpStr = null; } if (tmpStr == null) { throw new ArgumentNullException(accessStr + "host"); } string host = tmpStr; try { tmpStr = attributes["transport"] as string; } catch { tmpStr = null; } if (tmpStr == null) { throw new ArgumentNullException(accessStr + "transport"); } TransportType transport; try { transport = (TransportType)Enum.Parse(typeof(TransportType), tmpStr, true); } catch (Exception exception) { if (exception is ThreadAbortException || exception is StackOverflowException || exception is OutOfMemoryException) { throw; } throw new ArgumentException(accessStr + "transport", exception); } try { tmpStr = attributes["port"] as string; } catch { tmpStr = null; } if (tmpStr == null) { throw new ArgumentNullException(accessStr + "port"); } if (string.Compare(tmpStr, "All", StringComparison.OrdinalIgnoreCase) == 0) { tmpStr = "-1"; } int port; try { port = Int32.Parse(tmpStr, NumberFormatInfo.InvariantInfo); } catch (Exception exception) { if (exception is ThreadAbortException || exception is StackOverflowException || exception is OutOfMemoryException) { throw; } throw new ArgumentException(SR.GetString(SR.net_perm_invalid_val, accessStr + "port", tmpStr), exception); } if (!ValidationHelper.ValidateTcpPort(port) && port != SocketPermission.AllPorts) { throw new ArgumentOutOfRangeException("port", port, SR.GetString(SR.net_perm_invalid_val, accessStr + "port", tmpStr)); } listToAdd.Add(new EndpointPermission(host, port, transport)); } else { // improper tag found, just ignore } } }
public override void RunCode(int arg) { switch (arg) { case 119: { int a119 = 111 + 222; Console.WriteLine($"a : {a119}"); int b119 = a119 - 100; Console.WriteLine($"b : {b119}"); int c119 = b119 * 10; Console.WriteLine($"c : {c119}"); double d119 = c119 / 6.3; Console.WriteLine($"d : {d119}"); Console.WriteLine($"22 / 7 = {22 / 7}({22 % 7})"); } break; case 121: { int a121 = 10; Console.WriteLine(a121++); Console.WriteLine(++a121); Console.WriteLine(a121--); Console.WriteLine(--a121); } break; case 123: { string result123 = "123" + "456"; Console.WriteLine(result123); result123 = "Hello" + " " + "World!"; Console.WriteLine(result123); } break; case 124: { Console.WriteLine($"3 > 4 : {3 > 4}"); Console.WriteLine($"3 >= 4 : {3 >= 4}"); Console.WriteLine($"3 < 4 : {3 < 4}"); Console.WriteLine($"3 <= 4 : {3 <= 4}"); Console.WriteLine($"3 == 4 : {3 == 4}"); Console.WriteLine($"3 != 4 : {3 != 4}"); } break; case 126: { Console.WriteLine("Testing && ... "); Console.WriteLine($"1 > 0 && 4 < 5 : {1 > 0 && 4 < 5}"); Console.WriteLine($"1 > 0 && 4 > 5 : {1 > 0 && 4 > 5}"); Console.WriteLine($"1 == 0 && 4 > 5 : {1 == 0 && 4 > 5}"); Console.WriteLine($"1 == 0 && 4 < 5 : {1 == 0 && 4 < 5}"); Console.WriteLine("\nTesting || ... "); Console.WriteLine($"1 > 0 || 4 < 5 : {1 == 0 || 4 < 5}"); Console.WriteLine($"1 > 0 || 4 > 5 : {1 == 0 || 4 > 5}"); Console.WriteLine($"1 == 0 || 4 > 5 : {1 == 0 || 4 > 5}"); Console.WriteLine($"1 == 0 || 4 < 5 : {1 == 0 || 4 < 5}"); Console.WriteLine("\nTesting ! ..."); Console.WriteLine($"!True : {!true}"); Console.WriteLine($"!False : {!false}"); } break; case 128: { string result128 = (10 % 2) == 0 ? "짝수" : "홀수"; Console.WriteLine(result128); } break; case 130: { ArrayList a130 = null; a130?.Add("야구"); // a130?.이 null을 반환하므로 Add() 메소드는 호출되지 않음 a130?.Add("축구"); Console.WriteLine($"Count : {a130?.Count}"); Console.WriteLine($"{a130?[0]}"); Console.WriteLine($"{a130?[1]}"); a130 = new ArrayList(); a130?.Add("야구"); a130?.Add("축구"); Console.WriteLine($"Count : {a130?.Count}"); Console.WriteLine($"{a130?[0]}"); Console.WriteLine($"{a130?[1]}"); } break; case 134: { Console.WriteLine("Testing << ..."); int a134 = 1; Console.WriteLine("a : {0:D5} (0x{0:X8})", a134); Console.WriteLine("a << 1 : {0:D5} (0x{0:X8})", a134 << 1); Console.WriteLine("a << 2 : {0:D5} (0x{0:X8})", a134 << 2); Console.WriteLine("a << 5 : {0:D5} (0x{0:X8})", a134 << 5); Console.WriteLine("\nTesting >>..."); int b134 = 255; Console.WriteLine("b : {0:D5} (0x{0:X8})", b134); Console.WriteLine("b >> 1 : {0:D5} (0x{0:X8})", b134 >> 1); Console.WriteLine("b >> 2 : {0:D5} (0x{0:X8})", b134 >> 2); Console.WriteLine("b >> 5 : {0:D5} (0x{0:X8})", b134 >> 5); Console.WriteLine("\nTesting >> 2..."); int c134 = -255; Console.WriteLine("c : {0:D5} (0x{0:X8})", c134); Console.WriteLine("c >> 1 : {0:D5} (0x{0:X8})", c134 >> 1); Console.WriteLine("c >> 2 : {0:D5} (0x{0:X8})", c134 >> 2); Console.WriteLine("c >> 5 : {0:D5} (0x{0:X8})", c134 >> 5); } break; case 138: { int a138 = 9; int b138 = 10; Console.WriteLine($"{a138} & {b138} : {a138 & b138}"); Console.WriteLine($"{a138} | {b138} : {a138 | b138}"); Console.WriteLine($"{a138} ^ {b138} : {a138 ^ b138}"); int c138 = 255; Console.WriteLine("~{0}(0x{0:X8}) : {1}(0x{1:X8})", c138, ~c138); } break; case 140: { int a140; a140 = 100; Console.WriteLine($"a = 100 : {a140}"); a140 += 90; Console.WriteLine($"a += 90 : {a140}"); a140 -= 80; Console.WriteLine($"a -= 80 : {a140}"); a140 *= 70; Console.WriteLine($"a *= 70 : {a140}"); a140 /= 60; Console.WriteLine($"a /= 60 : {a140}"); a140 %= 50; Console.WriteLine($"a %= 50 : {a140}"); a140 &= 40; Console.WriteLine($"a &= 40 : {a140}"); a140 |= 30; Console.WriteLine($"a |= 30 : {a140}"); a140 ^= 20; Console.WriteLine($"a ^= 20 : {a140}"); a140 <<= 10; Console.WriteLine($"a <<= 10 : {a140}"); a140 >>= 1; Console.WriteLine($"a >>= 1 : {a140}"); } break; case 142: { int?num142 = null; Console.WriteLine($"{num142 ?? 0}"); num142 = 99; Console.WriteLine($"{num142 ?? 0}"); string str142 = null; Console.WriteLine($"{str142 ?? "Default"}"); str142 = "Specific"; Console.WriteLine($"{str142 ?? "Default"}"); } break; } }