public void ReadTerms(MemoryStore rdfStore) { Resource[] terms = rdfStore.SelectObjects(mUri, P_HAS_TERM); Set <string> skipList = new Set <string>(); foreach (Literal term in terms) { mTokenizer.Text = Normalize(mIgnoreCase ? term.Value.ToLower() : term.Value); ArrayList <string> tokens = new ArrayList <string>(); foreach (string token in mTokenizer) { string tokenLower = token.ToLower(); if (!IsStopWord(tokenLower)) { tokens.Add(token); } } if (tokens.Count > 0 && !skipList.Contains(tokens.ToString())) { Term termObj = new Term(); termObj.mWords = tokens; mTerms.Add(termObj); skipList.Add(tokens.ToString()); } } }
public void Add_ShouldBeAbleToAddAnItemToAnEmptyArrayList() { // Act ArrayList.Add("a"); // Assert Assert.AreEqual("[a,,,]", ArrayList.ToString()); }
public void kıllmebabyklasor(string yol)//Verilen yoldaki Tüm klasörleri siler... { klsrlistl.Add(Directory.GetDirectories(yol)); for (int i = 0; i < klsrlistl.Count; i++) { Directory.Delete(klsrlistl.ToString()); } }
public void checksubfolders(ref ArrayList alcheck, string dir, string key) { string[] folders = Directory.GetDirectories(dir); foreach (string folder in folders) { string appdir = dir; //string foldername = folder.Substring(appdir.Length); string foldername = folder; if (!foldername.Contains("_svn") && (!foldername.Contains(".svn"))) { alcheck.Add(foldername); } } string key2 = key; string[] dirs = Directory.GetDirectories(dir); foreach (string dir2 in dirs) { checksubfolders(ref alcheck, dir2, key2); } for (int x = 0; x <= alcheck.Count; x++) { if (!alcheck.ToString().Contains("medium")) { try { Directory.CreateDirectory(Server.MapPath("~/App_Uploads_Img/" + key) + "\\medium"); } catch (Exception e) { //errorlabelauto.Text = e.Message; } } if (!alcheck.ToString().Contains("small")) { try { Directory.CreateDirectory(Server.MapPath("~/App_Uploads_Img/" + key) + "\\small"); } catch (Exception e) { //errorlabelauto.Text = e.Message; } } //if (!alcheck.ToString().Contains("large")) //{ // try // { // Directory.CreateDirectory(Server.MapPath("~/App_Uploads_Img/" + key) + "\\large"); // } // catch (Exception e) // { // errorlabelauto.Text = e.Message; // } //} } }
public void checksubfolders(ref ArrayList alcheck, string dir,string key) { string[] folders = Directory.GetDirectories(dir); foreach (string folder in folders) { string appdir = dir; //string foldername = folder.Substring(appdir.Length); string foldername = folder; if (!foldername.Contains("_svn") && (!foldername.Contains(".svn"))) { alcheck.Add(foldername); } } string key2 = key; string[] dirs = Directory.GetDirectories(dir); foreach (string dir2 in dirs) { checksubfolders(ref alcheck, dir2,key2); } for (int x = 0; x <= alcheck.Count; x++) { if (!alcheck.ToString().Contains("medium")) { try { Directory.CreateDirectory(Server.MapPath("~/App_Uploads_Img/" + key) + "\\medium"); } catch (Exception e) { //errorlabelauto.Text = e.Message; } } if (!alcheck.ToString().Contains("small")) { try { Directory.CreateDirectory(Server.MapPath("~/App_Uploads_Img/" + key) + "\\small"); } catch (Exception e) { //errorlabelauto.Text = e.Message; } } //if (!alcheck.ToString().Contains("large")) //{ // try // { // Directory.CreateDirectory(Server.MapPath("~/App_Uploads_Img/" + key) + "\\large"); // } // catch (Exception e) // { // errorlabelauto.Text = e.Message; // } //} } }
public static void SaveArff(string[] featureNames, LabeledDataset <BlogMetaData, SparseVector <double> > dataset, ClassType classType, string fileName) { using (StreamWriter w = new StreamWriter(fileName, /*append=*/ false, Encoding.ASCII)) { w.WriteLine("@RELATION r" + Guid.NewGuid().ToString("N")); w.WriteLine(); foreach (string featureName in featureNames) { w.WriteLine("@ATTRIBUTE " + featureName + " NUMERIC"); } w.Write("@ATTRIBUTE class "); ArrayList <string> classes = new ArrayList <string>(); ((IEnumerable <LabeledExample <BlogMetaData, SparseVector <double> > >)dataset).ToList().ForEach( x => classes.AddRange(AnalysisUtils.GetLabel(x.Label, classType).Split(','))); classes = new ArrayList <string>(classes.Distinct()); w.WriteLine(classes.ToString().Replace("( ", "{").Replace(" )", "}").Replace(" ", ",")); w.WriteLine(); w.WriteLine("@DATA"); foreach (LabeledExample <BlogMetaData, SparseVector <double> > lblEx in dataset) { foreach (string lblStr in AnalysisUtils.GetLabel(lblEx.Label, classType).Split(',')) { if (lblStr != "") { foreach (IdxDat <double> item in lblEx.Example) { w.Write(item.Dat + ","); } w.WriteLine(lblStr); } } } } }
private static int add(String numbers, String delimiter) { int returnValue = 0; ArrayList negativeNumbers = new ArrayList(); String[] numbersArray = Regex.Split(numbers, delimiter); for (int number = 0; number < numbersArray.Length; number++) { if (!(numbersArray[number].Trim() == null)) { int numberInt = int.Parse(numbersArray[number].Trim()); if (numberInt < 0) { negativeNumbers.Add(numberInt); } else if (numberInt <= 1000) { returnValue += int.Parse(numbersArray[number].Trim()); } } } if (negativeNumbers.Count > 0) { throw new Exception("Negatives not allowed: " + negativeNumbers.ToString()); } return(returnValue); }
public static void Main(string [] args) { ArrayList list = new ArrayList(); list.Add(100); Console.WriteLine(( int )list [0] == 100); list.Add(200); Console.WriteLine(( int )list [1] == 200); Console.WriteLine(list.Count == 2); // list.Insert(5, 500); // Error : System.ArgumentOutOfRangeException list.Insert(2, 300); Console.WriteLine(( int )list [2] == 300); list.Remove(100); Console.WriteLine(list.Count == 2); Console.WriteLine(( int )list [0] == 200); Console.WriteLine(( int )list [1] == 300); Console.WriteLine(list.ToString() == "System.Collections.ArrayList"); foreach (int v in list) { Console.WriteLine(v); } list.Add(10); list.Add(5); Console.WriteLine(list.Count == 4); // Console.WriteLine(list.Contains(10)); }
public static void Main(string[] args) { ArrayList list = new ArrayList(); list.Add(100); Console.WriteLine((int)list[0] == 100); list.Add(200); Console.WriteLine((int)list[1] == 200); Console.WriteLine(list.Count == 2); // list.Insert(5, 500); // Error: System.ArgumentOutOfRangeException list.Insert(2, 300); Console.WriteLine((int)list[2] == 300); list.Remove(100); // 제일 먼저 발견 된 100 삭제 Console.WriteLine(list.Count == 2); Console.WriteLine((int)list[0] == 200); Console.WriteLine((int)list[1] == 300); Console.WriteLine(list.ToString() == "System.Collections.ArrayList"); foreach (int v in list) { Console.WriteLine(v); } list.Add(10); list.Add(5); Console.WriteLine(list.Count == 4); // Todo: Cotains(), Sort()에 대한 Test case를 추가 하시오! Console.WriteLine(list.Contains(200) == true); Console.WriteLine(list.Contains(700) == false); }
public void GetAllDragons() { foreach (var dragon in dignity) { Console.WriteLine(dignity.ToString()); } }
public static void PublishData(ArrayList list) { foreach (var item in list) { Console.WriteLine(list.ToString()); } }
public static void FindAllSteepest(PathFinder pathFinder, int columns, int rows) { for (int i = 0; i < columns; i++) { for (int j = 0; j < rows; j++) { ArrayList stepOfPath = new ArrayList(pathFinder.GetStepOfPath(i, j)); int overAllSteepestPathSize = sampleMapInput.Length; int steepestPathSize = stepOfPath.Count; if ((overAllSteepestPathSize == 0 || overAllSteepestPathSize <= steepestPathSize) && steepestPathSize > 0) { if (overAllSteepestPathSize == steepestPathSize) { int overAllSteepDepth = CalculateSteepDepth(overAllstepOfPath); int currentSteepDepth = CalculateSteepDepth(stepOfPath); if (currentSteepDepth > overAllSteepDepth) { SetNewSteepestPath(stepOfPath); } } else { SetNewSteepestPath(stepOfPath); } } } } Console.WriteLine("El camino más empinado es " + overAllstepOfPath.ToString() + " de longitud " + overAllstepOfPath.Count + " y profundidad " + CalculateSteepDepth(overAllstepOfPath)); }
/// <summary> /// 登陆 /// </summary> /// <param name="loginName"></param> /// <param name="loginPwd"></param> /// <param name="jsonResult"></param> /// <returns></returns> public ResponseLogin PostLogin201909(string loginName, string loginPwd, string point, out string jsonResult) { jsonResult = string.Empty; ResponseLogin package = null; RequestPackage request = new RequestPackage(); request.Params.Add("username", System.Web.HttpUtility.UrlEncode(loginName)); request.Params.Add("password", System.Web.HttpUtility.UrlEncode(loginPwd)); request.Params.Add("appid", System.Web.HttpUtility.UrlEncode("otn")); request.Params.Add("answer", System.Web.HttpUtility.UrlEncode(point)); request.RequestURL = "/passport/web/login"; request.RefererURL = "/otn/resources/login.html"; request.Method = "post"; var RAIL_EXPIRATION = new Cookie("RAIL_EXPIRATION", TimeHelp.GetTimeStamp(DateTime.Now.AddDays(3)), "/", ".12306.cn"); var RAIL_DEVICEID = new Cookie("RAIL_DEVICEID", "K_89QjQR37H4I9URxTkeSVTXd2WIyViZrlUuxJA5A8p7xCM_3JGueLa4zc2t_T69vTHb1aDx-3ymUdCUrLXbPcb68Z-4pQAYOmF8i6rU0Nk7Q6HIfzMVHY5PIQPK16sfWaJc-Z08UcYMLepVR56jG1NrsBYZooob", "/", ".12306.cn"); TrainHttpContext.Cookie.Add(RAIL_EXPIRATION); TrainHttpContext.Cookie.Add(RAIL_DEVICEID); ArrayList list = TrainHttpContext.Send(request); if (list.Count == 2) { jsonResult = Encoding.UTF8.GetString(list[1] as byte[]); package = JsonConvert.DeserializeObject <ResponseLogin>(jsonResult); Log.Write(LogLevel.Info, jsonResult); } else { Log.Write(LogLevel.Info, list.ToString()); } return(package); }
public void Replace_s_email() { var dictionary = LoadFromFile(@"G:\textwords.csv"); foreach (Window window in Application.Current.Windows) { if (window.GetType() == typeof(MainWindow)) { foreach (string key in dictionary.Keys) { var message = key; if ((window as MainWindow).txtBox_body.Text.Contains(key)) { string textT = em.email_body; string koza = textT.Substring(textT.IndexOf(message) + message.Length + 1); message = ReplaceMessage(message, dictionary); em.Abbr = Full_abbr.ToString(); } } } } string content = JsonConvert.SerializeObject(em); File.WriteAllText(@"G:\ELM.json", content); }
public void ToString_WhenArrayListPassed_ShouldString(int[] array, string expected) { ArrayList arrayList = ArrayList.Create(array); string actual = arrayList.ToString(); Assert.AreEqual(expected, actual); }
public string ToString(Tokenizer tokenizer) { StringBuilder buffer = new StringBuilder(); if (tokenizer == null) { buffer.Append(_tokens.ToString()); } else { buffer.Append("["); for (int i = 0; i < _tokens.Count; i++) { var id = (int)_tokens[i]; var str = tokenizer.GetPatternDescription(id); if (i > 0) { buffer.Append(" "); } buffer.Append(str); } buffer.Append("]"); } if (_repeat) { buffer.Append(" *"); } return(buffer.ToString()); }
// IEnumerable public void DesplegarPersonas(IEnumerable _lista, string _separador) { foreach (Object obj in _lista) { ; } string salida; for (int i = 0; i < personas.Count; i++) { Persona per = (Persona)personas[i]; salida = per.GetNombre() + "\t"; salida += per.GetCedula().ToString() + "\t"; salida += per.GetApellido() + "\t"; salida += per.GetEdad().ToString() + "\t "; MessageBox.Show(salida); } //MessageBox.Show(_lista.) //MessageBox.Show("{0}{1}", _separador); //salida = Persona. //int cedula = Int32.Parse(richTextBoxCedula.Text); MessageBox.Show(personas.ToString()); //foreach (Object obj in _lista); //MessageBox.Show(""); //personas. }
/// <summary> /// 登陆 /// </summary> /// <param name="loginName"></param> /// <param name="loginPwd"></param> /// <param name="jsonResult"></param> /// <returns></returns> public ResponseLogin PostLogin(string loginName, string loginPwd, out string jsonResult) { jsonResult = string.Empty; ResponseLogin package = null; RequestPackage request = new RequestPackage(); request.Params.Add("username", System.Web.HttpUtility.UrlEncode(loginName)); request.Params.Add("password", System.Web.HttpUtility.UrlEncode(loginPwd)); request.Params.Add("appid", System.Web.HttpUtility.UrlEncode("otn")); request.RequestURL = "/passport/web/login"; request.RefererURL = "/otn/login/init"; request.Method = "post"; ArrayList list = TrainHttpContext.Send(request); if (list.Count == 2) { jsonResult = Encoding.UTF8.GetString(list[1] as byte[]); package = JsonConvert.DeserializeObject <ResponseLogin>(jsonResult); Log.Write(LogLevel.Info, jsonResult); } else { Log.Write(LogLevel.Info, list.ToString()); } return(package); }
public void TestRemove(int n, int[] expectedArray, int[] actualArray) { ArrayList expected = new ArrayList(expectedArray); ArrayList actual = new ArrayList(actualArray); actual.Remove(n); Assert.AreEqual(expected.ToString(), actual.ToString()); }
public void TestAddElementsToTheIndex(int[] values, int index, int[] expectedArray, int[] actualArray) { ArrayList expected = new ArrayList(expectedArray); ArrayList actual = new ArrayList(actualArray); actual.AddToTheIndex(values, index); Assert.AreEqual(expected.ToString(), actual.ToString()); }
public void TestAdd(int[] values, int[] expectedValues, int[] currentValues) { ArrayList expected = new ArrayList(expectedValues); ArrayList actual = new ArrayList(currentValues); actual.Add(values); Assert.AreEqual(expected.ToString(), actual.ToString()); }
public string toString() { ArrayList b = new ArrayList(this.digits); b = b.GetRange(0, this.lastdigit + 1); b.Reverse(); return((this.signbit == MINUS ? "-" : "") + b.ToString()); }
void DecodeMessage(String input) { int enginePacketType = int.Parse(input.Substring(0, 1)); switch (enginePacketType) { case 0: break; case 3: break; case 4: int socketPacketType = int.Parse(input.Substring(1, 1)); switch (socketPacketType) { case 0: break; case 2: string data = input.Substring(2); ArrayList j = JsonConvert.DeserializeObject <ArrayList>(data); string eventName = j[0].ToString(); if (eventName != "player:position") { Debug.Log(j.ToString()); } j.RemoveAt(0); try { DispatchEvent(eventName, j); } catch (Exception e) { throw e; Debug.LogError(e.Message); } // do stuff here break; default: Debug.LogWarning("Unknown socket packet type:" + socketPacketType.ToString()); break; } break; default: Debug.LogWarning("Unknown engine packet type: " + enginePacketType.ToString()); break; } }
public void ShowList_GodHelpMe() { string[] actual = new string[3] { "god", "help", "me" }; ArrayList <string> actualList = new ArrayList <string>(actual); Console.WriteLine(actualList.ToString()); }
public override string ToString() { var sb = new StringBuilder(); sb.AppendLine(_list.ToString()); sb.Append($"head: {front}, back: {back}"); return(sb.ToString()); }
public void ShowList_123() { int[] actual = new int[3] { 1, 2, 3 }; ArrayList <int> actualList = new ArrayList <int>(actual); Console.WriteLine(actualList.ToString()); }
public void ShowList_12_34_56() { double[] actual = new double[3] { 1.2, 3.4, 5.6 }; ArrayList <double> actualList = new ArrayList <double>(actual); Console.WriteLine(actualList.ToString()); }
public void IniciaServico(int port) { // Lista de usuários String [] x = { "A", "A" }; userList.Add(x); String [] y = { "B", "B" }; userList.Add(y); IPHostEntry ipHostInfo = Dns.GetHostByName("localhost"); IPEndPoint localEP = new IPEndPoint(ipHostInfo.AddressList[0], 100); Console.WriteLine("Local address and port: " + localEP.ToString()); Socket listener = new Socket(localEP.Address.AddressFamily, SocketType.Stream, ProtocolType.Tcp); Thread t; ArrayList ListThread = new ArrayList(); int i; String data = null; Socket handler; try { listener.Bind(localEP); listener.Listen(10); i = 0; while (true) { // Recebe o Socket handler = listener.Accept(); byte[] bytes = new byte[1024]; int bytesRec = handler.Receive(bytes); // int dado = (int) getObjectWithByteArray(bytes); // Console.WriteLine("Valor: " + dado.ToString()); ArrayList l = (ArrayList)getObjectWithByteArray(bytes); Console.WriteLine("Objeto: " + l.ToString()); Console.WriteLine("Valor: " + l.Count.ToString()); // Console.WriteLine("Valor: " + l.IndexOf(1).ToString()); i++; } } catch (Exception e) { Console.WriteLine("Error:" + e.ToString()); } }
public void AppendTest() { for (int i = 0; i < 4; i++) { list.Append(i); } Assert.AreEqual("{0, 1, 2, 3}", list.ToString()); }
public void UserInfoLoad(string UserId) //加载全部用户信息的函数,调用Database内的SqlSelect { ArrayList list = new ArrayList(); DataBase data = new DataBase(); data.SqlConnect(); list = data.SqlSelect("Manage_Id", "Manage", frm_Login.Login_Name, "="); textBox_ManageId.Text = list.ToString().Split('#')[0]; textBox_ManageName.Text = list.ToString().Split('#')[1]; if (list.ToString().Split('#')[3] == "超级管理员") { this.radion_SuperManage.Checked = true; } if (list.ToString().Split('#')[4] != null) { byte_Image2 = System.Text.Encoding.Default.GetBytes(list.ToString().Split('#')[4]); MemoryStream ms = new MemoryStream(byte_Image2); pictureBox_ManagePhoto.Image = Image.FromStream(ms); } }
private void button1_Click(object sender, EventArgs e) { con.Open(); SqlCommand sql = new SqlCommand("SELECT [UserName] FROM[Stock].[dbo].[login] ",con); SqlDataReader reader = sql.ExecuteReader(); while(reader.Read()) { list.Add(Convert.ToInt32(reader[0].ToString())); } con.Close(); MessageBox.Show(list.ToString()); }
/*! \brief Execute a promoter reaction as describe in the detailled reaction \details Once the tree is executed, the result is put in delta and used as follow : For each Product P in the operon : [P] += delta * RBSf * TerminatorFactor * beta(Maximal production) \param molecules The list of molecules */ public override void react(ArrayList molecules) { if (!_isActive) { if(_debug) Logger.Log("PromoterReaction::react !_isActive", Logger.Level.TRACE); return; } float delta = execNode(_formula, molecules); float energyCoef; float energyCostTot; if (delta > 0f && _energyCost > 0f && enableEnergy) { energyCostTot = _energyCost * delta; energyCoef = _medium.getEnergy() / energyCostTot; if (energyCoef > 1f) energyCoef = 1f; _medium.subEnergy(energyCostTot); } else energyCoef = 1f; delta *= energyCoef; foreach (Product pro in _products) { if(_debug) Logger.Log("PromoterReaction::react product="+pro, Logger.Level.TRACE); Molecule mol = ReactionEngine.getMoleculeFromName(pro.getName(), molecules); if( mol == null) Debug.Log("mol is null, pro.getName()="+pro.getName()+", molecules="+molecules.ToString()); if( pro == null) Debug.Log("pro is null"); float increase = delta * pro.getQuantityFactor() * _terminatorFactor * _beta * ReactionEngine.reactionsSpeed * _reactionSpeed; if(Logger.isLevel(Logger.Level.TRACE)) { if(_debug) Logger.Log("PromoterReaction::react increase="+increase +", delta:"+delta +", qFactor:"+pro.getQuantityFactor() +", tFactor:"+_terminatorFactor +", beta:"+_beta +", reactionsSpeed:"+ReactionEngine.reactionsSpeed +", reactionSpeed:"+_reactionSpeed , Logger.Level.TRACE ); } if (enableSequential) { float oldCC = mol.getConcentration(); mol.addConcentration(increase); float newCC = mol.getConcentration(); if(_debug) Logger.Log("PromoterReaction::react ["+mol.getName()+"]old="+oldCC +" ["+mol.getName()+"]new="+newCC , Logger.Level.TRACE ); } else { mol.addNewConcentration(increase); if(_debug) Logger.Log("PromoterReaction::react ["+mol.getName()+"]="+mol.getConcentration()+" addNewConcentration("+increase+")" , Logger.Level.TRACE ); } } }
private void Temporary() { int CValLength, RequestLength; if (ViewState["CurrentValue"].ToString() == "") { CValLength = 0; } else { CValLength = ViewState["CurrentValue"].ToString().Split(',').Length; } if (CheckForm("user_id") == "") { RequestLength = 0; } else { RequestLength = Request.Form["user_id"].Split(',').Length; } ArrayList tmpArray = new ArrayList(); if (Session["Usertemporary"].ToString() != "") { string[] ChangeAry = Session["Usertemporary"].ToString().Split(','); for (int j = 0; j < ChangeAry.Length; j++) { tmpArray.Add(ChangeAry[j]); } } string strUserID1 = ""; //移除這一頁舊有的資料 if (CValLength > 0) { string[] aBeforeUserID = ViewState["CurrentValue"].ToString().Split(','); foreach (string strUserID in aBeforeUserID) { if (tmpArray.Count > 0) //Session("Usertemporary")記錄未上傳前,所挑選的使用者 { foreach (string strTemp in tmpArray) { strUserID1 = strTemp.Split('_')[0]; if (strUserID1 == strUserID) { tmpArray.Remove(strTemp); break; } } } } } //新增這一頁的現有資料 string[] pick_user; if (CheckForm("user_id") != "") { pick_user = Request.Form["user_id"].Split(','); if (RequestLength > 0) { for (int i = 0; i < pick_user.Length; i++) { tmpArray.Add(pick_user[i]); } } } //將ArrayList轉成字串 string strTemporary = ""; if (tmpArray.ToString() != "" && tmpArray != null) { for (int k = 0; k < tmpArray.Count; k++) { strTemporary += tmpArray[k] + ","; } if (strTemporary != "") strTemporary = strTemporary.Substring(0, strTemporary.Length - 1); } Session["Usertemporary"] = strTemporary; }
public bool isInArrayList(string str, ArrayList _list) { bool _in = false; for (int i = 0; i < _list.Count; i++) { if (string.Compare(_list.ToString(), str) == 0) { _in = true; break; } } return _in; }
public void ReadTerms(MemoryStore rdfStore) { Resource[] terms = rdfStore.SelectObjects(mUri, P_HAS_TERM); Set<string> skipList = new Set<string>(); foreach (Literal term in terms) { mTokenizer.Text = Normalize(mIgnoreCase ? term.Value.ToLower() : term.Value); ArrayList<string> tokens = new ArrayList<string>(); foreach (string token in mTokenizer) { string tokenLower = token.ToLower(); if (!IsStopWord(tokenLower)) { tokens.Add(token); } } if (tokens.Count > 0 && !skipList.Contains(tokens.ToString())) { Term termObj = new Term(); termObj.mWords = tokens; mTerms.Add(termObj); skipList.Add(tokens.ToString()); } } }