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


C# Computer类代码示例

本文整理汇总了C#中Computer的典型用法代码示例。如果您正苦于以下问题:C# Computer类的具体用法?C# Computer怎么用?C# Computer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: Main

    static void Main()
    {
        var cpu = new Component("Generic CPU", "100 lv.");
        var videocard = new Component("Generic Video Card", "200 lv.", "overpriced");
        var motherboard = new Component("Generic Motherboard", "300 lv.");
        var hdd = new Component("Generic HDD", "5 lv.", "Opisanieeee");
        var videocard2 = new Component("NVIDIA", "999 lv.", "Oshte opisanieeeee");

        var computer = new Computer("Kumputar", "6 lv.", cpu, videocard, motherboard);
        var computer2 = new Computer("Po-qk kumputar", "3 lv.", cpu, videocard, motherboard, hdd);
        var computer3 = new Computer("Nai-qkq kumputar", "4 lv.", cpu, videocard2, motherboard, hdd);

        computer2.Display();
        Console.WriteLine();

        var computerList = new List<Computer>()
        {
            computer,
            computer2,
            computer3
        };

        var sortedComputerList = computerList.OrderBy(x => x.Price); //original price, not total price
        foreach (var pc in sortedComputerList)
        {
            pc.Display();
            Console.WriteLine("-----------------");
        }
    }
开发者ID:i-yotov,项目名称:Courses,代码行数:29,代码来源:PCCatalogMain.cs

示例2: Claim

 /// <summary>
 /// Called while the ProcessWaiter is locked: attempt to bind the computer to a process;
 /// this fails if it has already been bound to another process. The ProcessWaiter may
 /// be entered into multiple scheduling queues, and the first time it reaches the head
 /// of a queue it will be claimed successfully; it will be dropped after reaching the
 /// heads of other queues
 /// </summary>
 public Computer Claim()
 {
     System.Diagnostics.Debug.Assert(computer != null);
     Computer ret = computer;
     computer = null;
     return ret;
 }
开发者ID:knowledgehacker,项目名称:Dryad,代码行数:14,代码来源:Queues.cs

示例3: Export

        private static void Export(Computer data, string format, string outfile, string[] categories)
        {
            string outstr = "";
            switch (format)
            {
                case "txt":
                    outstr = ExportTxt(data, categories);
                    break;

                case "csv":
                    //outstr = data.ToCsv();
                    break;
            }
            if (outfile != null)
            {
                System.IO.StreamWriter file = new System.IO.StreamWriter(outfile);
                file.WriteLine(outstr.Replace("\n", "\r\n"));

                file.Close();
            }
            else
            {
                Console.WriteLine(outstr);
                // print to screen
            }
        }
开发者ID:sapozhnikovay,项目名称:wminfo,代码行数:26,代码来源:Program.cs

示例4: Main

    static void Main()
    {
        List<Computer> catalog = new List<Computer>();
        List<Component> components1 = new List<Component>();
        components1.Add(new Component("HDD", 500.00m));
        components1.Add(new Component("CPU", 250.12m));
        Computer hp = new Computer("HP", components1);

        List<Component> components2 = new List<Component>();
        components2.Add(new Component("CPU", 400.01m));
        components2.Add(new Component("RAM", 102.00m));
        components2.Add(new Component("Graphics card", 100));
        Computer sony = new Computer("Sony", components2);


        catalog.Add(hp);
        catalog.Add(sony);

        var sortCatalog = catalog.OrderBy(computer => computer.Price);

        foreach (var computer in sortCatalog)
        {
            Console.WriteLine(computer);
        }
    }
开发者ID:emilrr,项目名称:SoftUni-Fundamental-Level,代码行数:25,代码来源:PCCatalog.cs

示例5: Main

    static void Main()
    {
        Component graphicsCard = new Component("nVidia", 350m);
        Component hdd = new Component("WesternDigital", 130m, "1TB 3.5 HDD (7200 оборота/минута)");
        Component ram = new Component("AsRock", 210m, "8GB (2x 4096MB) - DDR3, 1600Mhz");
        Component motherboard = new Component("AsRock", 520m);
        Component processor = new Component("Intel", 600m, "Core i5-4460 (4-ядрен, 3.20 - 3.40 GHz, 6MB кеш)");
        Component powerSupply = new Component("Superpowerrr", 250m, "5000W");
        Component biggerHdd = new Component("WesternDigital", 189m, "2TB 3.5 HDD");

        Computer lenovo = new Computer("Lenovo", graphicsCard, hdd, ram, motherboard, processor, powerSupply);
        Computer dell = new Computer("Dell", graphicsCard, biggerHdd, ram, motherboard, processor, powerSupply);
        Computer acer = new Computer("Acer", graphicsCard, ram, processor, motherboard);

        List<Computer> computers = new List<Computer>();
        computers.Add(lenovo);
        computers.Add(dell);
        computers.Add(acer);

        computers = computers.OrderBy(computer => computer.Price).ToList();

        foreach (var computer in computers)
        {
            computer.printInfo();
            Console.WriteLine();
        }

    }
开发者ID:vvulevv,项目名称:OOP-Defining-Class,代码行数:28,代码来源:PCCatalog.cs

示例6: Main

    private static void Main()
    {
        List<Computer> computers = new List<Computer>();

        Computer PC1 = new Computer(
                name: "ASUS",
                motherboard: new Component("Asus AK-47", 334m, "mini form factor"),
                processor: new Component("i7 2345", 234m, "64 cores"),
                ram: new Component("32GB", 200m, "DDR5"));

        Computer PC2 = new Computer(
            name: "GigaBUUUG",
            motherboard: new Component("Gigabyte AZ32", 144m, "mini form factor"),
            processor: new Component("i5 2345", 134m, "32 cores"),
            ram: new Component("16GB", 100m, "DDR5"));

        Computer PC3 = new Computer(
            name: "Handmade",
            motherboard: new Component("Marmalad duno", 112m),
            processor: new Component("i3 2200", 104m),
            ram: new Component("8GB", 80m));

        computers.Add(PC1);
        computers.Add(PC2);
        computers.Add(PC3);

        computers = computers.OrderBy(o => o.totalPrice).ToList();

        foreach (var computer in computers)
        {
            Console.WriteLine(computer);
            Console.WriteLine();
        }
    }
开发者ID:dimitarIT,项目名称:2.1.OOP,代码行数:34,代码来源:PC_Catalogue.cs

示例7: Calculate

    private decimal Calculate(Computer computer)
    {
        var components = computer.Components;
        decimal price = components.Sum(component => component.Price);

        return price;
    }
开发者ID:DimitarLilov,项目名称:Object-Oriented-Programming,代码行数:7,代码来源:Computer.cs

示例8: Main

    static void Main()
    {
        // Play a sound with the Audio class:
        Audio myAudio = new Audio();
        Console.WriteLine("Playing sound...");
        myAudio.Play(@"c:\WINDOWS\Media\chimes.wav");

        // Display time information with the Clock class:
        Clock myClock = new Clock();
        Console.Write("Current day of the week: ");
        Console.WriteLine(myClock.LocalTime.DayOfWeek);
        Console.Write("Current date and time: ");
        Console.WriteLine(myClock.LocalTime);

        // Display machine information with the Computer class:
        Computer myComputer = new Computer();
        Console.WriteLine("Computer name: " + myComputer.Name);

        if (myComputer.Network.IsAvailable)
        {
            Console.WriteLine("Computer is connected to network.");
        }
        else
        {
            Console.WriteLine("Computer is not connected to network.");
        }
    }
开发者ID:terryjintry,项目名称:OLSource1,代码行数:27,代码来源:how-to--use-the-my-namespace--csharp-programming-guide-_2.cs

示例9: Main

    static void Main(string[] args)
    {
        Component intelGraphicsCard = new Component("Intel HD Graphics 4400", "Mnogo moshtna", 499.0m);
        Component asrockMotherboard = new Component("Asrock 123412", 199.0m);
        Component intelProcessor = new Component("Intel i5 43-123512", 600.0m);

        Computer MyComp = new Computer("Lenovo", new List<Component> { intelGraphicsCard, asrockMotherboard, intelProcessor });


        Component nvidiaGraphicsCar = new Component("NVIDIA GeForce GTX 880M", " (4GB GDDR5)", (decimal)1000);
        Component inteli7Processor = new Component("Intel Core i7-4700HQ", "(4-ядрен, 2.40 - 3.40 GHz, 6MB кеш)", (decimal)300);
        Component asusMotherboard = new Component("Asus Motherboard", (decimal)200);

        Computer otherComp = new Computer("Asus", new List<Component> { nvidiaGraphicsCar, inteli7Processor, asusMotherboard });

        Component nGraphic = new Component("NVIDIA GeForce GTX 100000", " (64GB GDDR8)", (decimal)80000);
        Component i8Processor = new Component("Intel i8 NNNN", (decimal)1000);
        Component AMotherboard = new Component("Motherboard", (decimal)900);

        Computer mostExpensive = new Computer("HP", new List<Component> { nGraphic, i8Processor, AMotherboard});

        List<Computer> computers = new List<Computer>() { mostExpensive, otherComp, MyComp,};

        computers.OrderByDescending(computer => computer.Price).ToList().ForEach(computer => Console.WriteLine(computer.ToString()));
    }
开发者ID:StanislavBozhilov,项目名称:SoftwareUniversity,代码行数:25,代码来源:PCCatalog.cs

示例10: JSONSystemData

    public JSONSystemData(Computer computer, bool names)
    {
        // Create lists
        Voltages = new List<JSONNameValue>();
        Temp = new List<JSONNameValue>();
        Fans = new List<JSONNameValue>();

        // Find the superIO chip.
        IHardware motherboard = computer.Hardware.FirstOrDefault(h => h.HardwareType == HardwareType.Mainboard && h.SubHardware.Length > 0);
        IHardware superIO;

        if (motherboard != null) {
            superIO = motherboard.SubHardware[0];

            foreach (ISensor s in superIO.Sensors) {
                String name;
                if (names) name = s.Name;
                else name = "";

                switch (s.SensorType) {
                    case SensorType.Voltage: Voltages.Add(new JSONNameValueFloat(name, (float)s.Value, 3)); break;
                    case SensorType.Fan: Fans.Add(new JSONNameValueInt(name, (int)s.Value)); break;
                    case SensorType.Temperature: Temp.Add(new JSONNameValueFloat(name, (float)s.Value, 1)); break;
                }
            }
        }
    }
开发者ID:sakisds,项目名称:Icy-Monitor,代码行数:27,代码来源:JSONSystemData.cs

示例11: Insert

 ///<summary>Inserts one Computer into the database.  Returns the new priKey.</summary>
 internal static long Insert(Computer computer)
 {
     if(DataConnection.DBtype==DatabaseType.Oracle) {
         computer.ComputerNum=DbHelper.GetNextOracleKey("computer","ComputerNum");
         int loopcount=0;
         while(loopcount<100){
             try {
                 return Insert(computer,true);
             }
             catch(Oracle.DataAccess.Client.OracleException ex){
                 if(ex.Number==1 && ex.Message.ToLower().Contains("unique constraint") && ex.Message.ToLower().Contains("violated")){
                     computer.ComputerNum++;
                     loopcount++;
                 }
                 else{
                     throw ex;
                 }
             }
         }
         throw new ApplicationException("Insert failed.  Could not generate primary key.");
     }
     else {
         return Insert(computer,false);
     }
 }
开发者ID:nampn,项目名称:ODental,代码行数:26,代码来源:ComputerCrud.cs

示例12: Get_test

        public void Get_test()
        {
            // arrange
            var maker = "Intel";
            var processorSpeed = 500;
            var ramSize = 2000;
            processors[0] = new Dictionary<string, object>
            {
                { "Maker", maker},
                { "Speed", processorSpeed},
                { "RamId", 0 }
            };
            rams[0] = new Dictionary<string, object>
            {
                { "Size", ramSize }
            };
            var aggregatorProvider = aggregatorProviderMock.Object;
            var processorModel = new ProcessorModel(0, processorCollectionMock.Object);
            var ramModel = new RAMModel(0, ramCollectionMock.Object);
            var computer = new Computer(aggregatorProvider, processorModel);
            var ram = new RAM(aggregatorProvider, ramModel);
            aggregatorProvider.Save(computer, ram);

            // act and assert
            computer.RAM.Size.Should().Be(ramSize);
            computer.ProcessorSpeed.Should().Be(processorSpeed);
            computer.Maker.Should().Be(maker);
        }
开发者ID:iroq,项目名称:trellis,代码行数:28,代码来源:NestedLazyAggregatorTests.cs

示例13: ComputeEngine

    public ComputeEngine(FractalSettings settings)
    {
        int height = settings.Height;		// note that we need to use these locals to avoid creating tens of thousands of BigFloat objects in the loop
        int width = settings.Width;
        m_samples = new float[width, height];
        for (int v = 0; v < height; ++v)
            for (int h = 0; h < width; ++h)
                m_samples[h, v] = float.NaN;

        //		Console.WriteLine("dx: {0:F}", settings.Extent.Width/width);

        const int NumThreads = 4;
        m_computers = new Computer[NumThreads];

        int startRow = 0;
        int numRows = height/NumThreads;
        for (int i = 0; i < NumThreads; ++i)
        {
            if (i + 1 == NumThreads)
                numRows = height - startRow;

            m_computers[i] = new Computer(settings, startRow, numRows, m_samples);
            startRow += numRows;
        }
    }
开发者ID:afrog33k,项目名称:mcocoa,代码行数:25,代码来源:ComputeEngine.cs

示例14: JSONGPUData

    public JSONGPUData(Computer computer, bool names)
    {
        // Create lists
        Temp = new List<JSONNameValue>();
        Fans = new List<JSONNameValue>();
        Load = new List<JSONNameValue>();
        Clock = new List<JSONNameValue>();

        IEnumerable<IHardware> gpus = computer.Hardware.Where(h => h.HardwareType == HardwareType.GpuNvidia || h.HardwareType == HardwareType.GpuAti);

        foreach (IHardware h in gpus) {
            foreach (ISensor s in h.Sensors) {
                String name;
                if (names) name = s.Name;
                else name = "";

                switch (s.SensorType) {
                    case SensorType.Temperature: Temp.Add(new JSONNameValueFloat(name, (float)s.Value)); break;
                    case SensorType.Fan: Fans.Add(new JSONNameValueInt(name, (int)s.Value)); break;
                    case SensorType.Load: Load.Add(new JSONNameValueInt(name, (int)s.Value)); break;
                    case SensorType.Clock: Clock.Add(new JSONNameValueInt(name, (int)s.Value)); break;
                }
            }
        }
    }
开发者ID:sakisds,项目名称:Icy-Monitor,代码行数:25,代码来源:JSONGPUData.cs

示例15: Main

    static void Main(string[] args)
    {
        Component ram1 = new Component("8GB RAM", 116);
        Component ram2 = new Component("4GB RAM", 72);

        Component hdd1 = new Component("500GB HHD", 78);
        Component hdd2 = new Component("1TB HDD", 131);
        Component hdd3 = new Component("1TB SSD", 370);

        Component gpu1 = new Component("None", 0);
        Component gpu2 = new Component("ATI 5890", 255);
        Component gpu3 = new Component("NVidia GTX Titan", 598);

        Component cpu1 = new Component("Intel Core i3 2.4 GHz", 78);
        Component cpu2 = new Component("Intel Core i5 3.2 GHz", 131);
        Component cpu3 = new Component("Intel Core i7 4.0 GHz", 515);

        Computer PC1 = new Computer("PC1", new List<Component>() { ram1, hdd1, gpu1, cpu1 });
        Computer PC2 = new Computer("PC2", new List<Component>() { ram2, hdd2, gpu2, cpu2 });
        Computer PC3 = new Computer("PC4", new List<Component>() { ram1, hdd3, gpu3, cpu3 });
        Computer PC4 = new Computer("UnknownTrash");

        List<Computer> myList = new List<Computer>() { PC1, PC2, PC3, PC4 };
        myList = myList.OrderBy(pr => pr.Price).ToList();
        foreach (var pc in myList)
        {
            Console.WriteLine(pc.ToString());
        }
    }
开发者ID:rextor92,项目名称:OOP-November2015,代码行数:29,代码来源:Test.cs


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