当前位置: 首页>>代码示例>>C#>>正文


C# Object.OfType方法代码示例

本文整理汇总了C#中System.Object.OfType方法的典型用法代码示例。如果您正苦于以下问题:C# Object.OfType方法的具体用法?C# Object.OfType怎么用?C# Object.OfType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Object的用法示例。


在下文中一共展示了Object.OfType方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: llenaUnidadNegocio

 public void llenaUnidadNegocio()
 {
     NegocioService oNegocioService = new NegocioService();
     System.Object[] ItemObject = new System.Object[oNegocioService.GetUnidadesNegocioId().Length];
     for (int i = 0; i < oNegocioService.GetUnidadesNegocioId().Length; i++)
     {
         ItemObject[i] = oNegocioService.GetUnidadesNegocioId()[i];
     }
     cmbUnidadNegocio.Items.AddRange(ItemObject);
     List<int> lst = ItemObject.OfType<int>().ToList();
     cmbUnidadNegocio.Text = lst.Min().ToString();
 }
开发者ID:jegamboafuentes,项目名称:NetTurnadorClient,代码行数:12,代码来源:GeneraTurno.cs

示例2: llenaUnidadNegocio

 public void llenaUnidadNegocio()
 {
     lblUnidadesNegocio.Text = oNegocioService.GetUnidadesNegocio().Length.ToString();
     System.Object[] ItemObject = new System.Object[oNegocioService.GetUnidadesNegocioDescripcion().Length];
     for (int i = 0; i < oNegocioService.GetUnidadesNegocioDescripcion().Length; i++)
     {
         ItemObject[i] = oNegocioService.GetUnidadesNegocioDescripcion()[i];
     }
     cmbUnidadesNegocioNombre.Items.AddRange(ItemObject);
     List<String> lst = ItemObject.OfType<String>().ToList();
     cmbUnidadesNegocioNombre.Text = lst.Min().ToString();
 }
开发者ID:jegamboafuentes,项目名称:NetTurnadorClient,代码行数:12,代码来源:GetUnidadNegocio.cs

示例3: eachStation

        /// <summary>
        /// Call an intrastage query for each station where Intrastage is enabled. 
        /// </summary>
        /// <param name="thisCell"></param>
        /// <param name="i"></param>
        /// <param name="j"></param>
        /// <returns></returns>
        public override StationData eachStation(StationData thisCell, int i, int j)
        {
            //Check if intrastage is enabled (bool)
            if (thisCell.Intrastage)
            {
                List<String> newData = new List<String>();
                //Perform the multiple queries
                myConnection = new SqlConnection("Data Source=BHX4SQ01;Initial Catalog=IS_Main;User ID=is_viewer;Password=is!viewer");
                //Try to open the connection, otherwise log the error.
                try
                {
                    myConnection.Open();
                }
                catch (Exception e)
                {

                    ConsolePost newPost = new ConsolePost();
                    newPost.type = 4;
                    newPost.issue = "Could not connect to Intrastage";
                    newPost.trace = e.ToString();
                    Program.updates.Add(newPost);
                }
                //try to read the data and parse it appropriately.
                try
                {
                    SqlDataReader myReader = null;
                    String thisQuery = queryPartOne +
                thisCell.Station_Name +
                queryPartTwo;

                    SqlCommand myCommand = new SqlCommand(thisQuery, myConnection);
                    myReader = myCommand.ExecuteReader();
                    while (myReader.Read())
                    {

                        Object[] thisData = new Object[myReader.FieldCount];

                        myReader.GetValues(thisData);

                        switch (thisData[1].ToString())
                        {
                            case "Passed":
                                thisData[1] = "#AAD178";
                                break;
                            case "Error":
                                thisData[1] = "#F7BE64";
                                break;
                            case "Aborted":
                                thisData[1] = "#6AD2EB";
                                break;
                            case "Terminated":
                                thisData[1] = "#6AD2EB";
                                break;
                            case "Failed":
                                thisData[1] = "#EF8A80";
                                break;
                            default:
                                thisData[1] = "#808080";
                                break;
                        }

                        newData = thisData.OfType<String>().ToList();
                    }
                    myReader.Close();
                    myConnection.Close();
                }
                catch (Exception e)
                {
                    ConsolePost newPost = new ConsolePost();
                    newPost.type = 4;
                    newPost.issue = "Could not read data";
                    newPost.trace = e.ToString();
                    Program.updates.Add(newPost);
                }

                thisCell.cellData = newData;

            }
            return thisCell;
        }
开发者ID:elmarti,项目名称:dataparser,代码行数:87,代码来源:Intrastage.cs

示例4: PythonLinqGenericArgs

          public void PythonLinqGenericArgs()
          {
              var start = new Object[] {1, "string", 4, Guid.Empty, 6};
              var expected = start.OfType<int>().Skip(1).First();
              var actual = RunPythonHelper(Impromptu.Linq(start), @"
import System
result = linq.OfType[System.Int32]().Skip(1).First()

");
              Assert.AreEqual(expected,actual);
          }
开发者ID:bbenzikry,项目名称:impromptu-interface,代码行数:11,代码来源:Linq.cs


注:本文中的System.Object.OfType方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。