• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# Car类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: Main

        static void Main()
        {
            var bag = new PriorityQueue<Car>();

            var opel = new Car
            {
                Model = "Opel",
                Price = 1000
            };
            var mercedes = new Car
            {
                Model = "Mercedes",
                Price = 5000
            };

            var citroen = new Car
            {
                Model = "Citroen",
                Price = 3000
            };

            bag.Enqueue(opel);
            bag.Enqueue(mercedes);
            bag.Enqueue(citroen);

            while(bag.Count > 0)
            {
                var car = bag.Dequeue();
                Console.WriteLine("{0} -> {1}",car.Model, car.Price);
            }
        }
开发者ID:radkomitev,项目名称:Telerik-Academy,代码行数:31,代码来源:StartUp.cs


示例2: should_be_able_to_pick_car

 public void should_be_able_to_pick_car()
 {
     smartParkingBoy.Manage(new ParkingLot());
     var car = new Car();
     var token = smartParkingBoy.Park(car);
     Assert.Same(car, smartParkingBoy.Pick(token));
 }
开发者ID:chenbojian,项目名称:OO,代码行数:7,代码来源:SmartParkingBoyFact.cs


示例3: Main

        static void Main(string[] args)
        {
            //Printing  -  Genreic List Version Atribute  - Problem.04
            var result = typeof(GenericList<int>).GetCustomAttributes(true).First();
            Console.WriteLine(result);

            GenericList<Car> cars = new GenericList<Car>();

            Car ferrari = new Car("Ferrari", "F360", 155000);
            cars.Add(ferrari);
            Car alfa = new Car("Alfa", "Spider", 95000);
            cars.Add(alfa);
            Car mercedes = new Car("Mercedes", "AMG SL65", 135000);
            cars.Add(mercedes);
            Car lada=new Car("Lada","1500",2500);

            Console.WriteLine(cars[0]);
            Console.WriteLine(cars[1]);
            Console.WriteLine(cars[2]);
            Console.WriteLine("List size {0}",cars.Size);
            Console.WriteLine("List capacity {0}",cars.Capacity);

            cars.InsertAt(lada, 2);
            Console.WriteLine(cars[2]);
            Console.WriteLine("List size {0}", cars.Size);
            Console.WriteLine(cars.Contains(ferrari));
        }
开发者ID:AdrianDamyanov,项目名称:CSharpOOP,代码行数:27,代码来源:MainClass.cs


示例4: Park

 public Ticket Park(Car car)
 {
     if (!IsNotFull()) throw new ParkinglotFullException();
     var ticket = new Ticket();
     carList.Add(ticket, car);
     return ticket;
 }
开发者ID:Jennifer-fu,项目名称:Parkinglot,代码行数:7,代码来源:Parkinglot.cs


示例5: SetCarInfo

 private bool SetCarInfo(Car car)
 {
     carNoStyle_label.Text = car.carStyle;
     carNo_label.Text = car.carNo;
     carFrameNo_label.Text = car.carFrameNo;
     return true;
 }
开发者ID:kooyou,项目名称:TrafficFinesSystem,代码行数:7,代码来源:CarFinesWeb.aspx.cs


示例6: PrepareData

		public void PrepareData()
		{
			ISession s = OpenSession();
			ITransaction txn = s.BeginTransaction();

			Car car = new Car();
			car.Id = GetNewId();
			car.Vin="123c";
			car.Owner="Kirsten";
			s.Save(car);

			Truck truck = new Truck();
			truck.Id = GetNewId();
			truck.Vin = "123t";
			truck.Owner="Steve";
			s.Save(truck);

			SUV suv = new SUV();
			suv.Id = GetNewId();
			suv.Vin = "123s";
			suv.Owner="Joe";
			s.Save(suv);

			Pickup pickup = new Pickup();
			pickup.Id = GetNewId();
			pickup.Vin = "123p";
			pickup.Owner="Cecelia";
			s.Save(pickup);

			txn.Commit();
			s.Close();
		}
开发者ID:marchlud,项目名称:nhibernate-core,代码行数:32,代码来源:NativeSQLBulkOperations.cs


示例7: SetUp

        public void SetUp()
        {
            _game = new Game();

            _gameObject =
                Object.Instantiate(Resources.LoadAssetAtPath("Assets/CarRed.prefab", typeof(GameObject))) as GameObject;
            if (_gameObject == null) return;
            _autoBehaviour = _gameObject.AddComponent<CarBehaviour>();
            _car = new Car(_autoBehaviour);

            _gameObjectOther =
                Object.Instantiate(Resources.LoadAssetAtPath("Assets/CarBlue.prefab", typeof(GameObject))) as GameObject;
            if (_gameObjectOther == null) return;
            _gameObjectOther.AddComponent<CarBehaviour>();
            _carOther = new Car(_gameObjectOther.GetComponent<CarBehaviour>());

            List<Car> cars = new List<Car>();
            for (int i = 0; i < GameData.CARS_AMOUNT; i++)
            {
                Car c = new Car(_autoBehaviour);
                cars.Add(c);
            }
            MainScript.Cars = cars;
            MainScript.SelfCar = new Car { CarObject = _autoBehaviour };
        }
开发者ID:KvanNes,项目名称:Contextproject-Group5,代码行数:25,代码来源:Game_Test.cs


示例8: describe_compression_ratio

    void describe_compression_ratio()
    {
        Car car = null;

        new Tuples<int, int, double>
        {
            { 7, 87, .28 },
            { 8, 92, .30 },
            { 9, 96, .32 }
        }.Do(
        (compressionRatio, octane, effeciency) =>
        {
            context["car has compression ratio of {0} to 1".With(compressionRatio)] = () =>
            {
                before = () => car = new Car(compressionRatio);

                it["should have octane requirement of {0}".With(octane)] = () =>
                {
                    car.OctaneRequirement.should_be(octane);
                };

                it["should have brake thermal efficiency of {0}%".With(effeciency * 100)] = () =>
                {
                    car.BrakeThermalEffeciency.should_be(effeciency);
                };
            };
        });
    }
开发者ID:DevlinLiles,项目名称:NSpec,代码行数:28,代码来源:describe_car.cs


示例9: Main

  public static void Main()
  {
    // Car porsche = new Car("2014 Porsche 911", 114991, 7864);
    // Car ford = new Car("2011 Ford F450", 55995, 14241);
    // Car lexus = new Car("2013 Lexus RX 350", 44700, 20000);
    // Car mercedes = new Car("Mercedes Benz CLS550", 39900, 37979);
    // Car jalopy = new Car("Uncle Beater's Ride", 500, 250000, "Beater");

    Car newCar = new Car();
    newCar.SetMakeModel("Chevy Crossover");
    newCar.SetMiles(83000);
    newCar.SetPrice(15000);
    newCar.SetCondition("Good");
    Console.WriteLine(newCar.GetMakeModel());
    Console.WriteLine("Miles: " + newCar.GetMiles());
    Console.WriteLine("Price: $" + newCar.GetPrice());
    Console.WriteLine("Condition: " + newCar.GetCondition());
    Console.WriteLine(newCar.GetMakeModel() + " is in " + newCar.GetCondition() + " condition.");




    // Console.WriteLine("Enter maximum price: ");
    // string stringMaxPrice = Console.ReadLine();
    // int maxPrice = int.Parse(stringMaxPrice);
    //
    // Console.WriteLine("Enter maximum miles: ");
    // string stringMaxMiles = Console.ReadLine();
    // int maxMiles = int.Parse(stringMaxMiles);


  }
开发者ID:cbkinor,项目名称:cars,代码行数:32,代码来源:Car.cs


示例10: Start

 void Start()
 {
     car = GetComponent<Car>();
     maxHealth = health;
     damageParticles.maxParticles = 0;
     damageParticles.Play();
 }
开发者ID:marrony,项目名称:ncar,代码行数:7,代码来源:CarDamage.cs


示例11: Main

        static void Main(string[]args)
        {
            var car = new Car() {
                Manufacturer = "Mercedes-Benz",
                Model = "New A Class",
                Colour = "Gray"
            };

            var carRepository = new MongoDbRepository<Car>();

            Console.WriteLine("Inserting car");
            var insertResult = carRepository.Insert(car);

            Console.WriteLine("Updating car");
            car.Colour = "Blue";
            var updateResult = carRepository.Update(car);

            Console.WriteLine("Search cars");
            var searchResult = carRepository.SearchFor(c => c.Colour == "Blue");

            Console.WriteLine("Get all cars");
            var getAllResult = carRepository.GetAll();

            Console.WriteLine("Getting car by id");
            var getByIdResult = carRepository.GetById(car.Id);

            Console.WriteLine("Deleting car");
            var deleteResult = carRepository.Delete(car);

            Console.Write("Press any key to continue...");
            Console.ReadKey();
        }
开发者ID:huoxudong125,项目名称:MongoDbRepository,代码行数:32,代码来源:Program.cs


示例12: Garage

 public Garage()
 {
     carArray[0] = new Car("Rusty", 30);
     carArray[1] = new Car("Clunker", 55);
     carArray[2] = new Car("Zippy", 30);
     carArray[3] = new Car("Fred", 30);
 }
开发者ID:walrus7521,项目名称:code,代码行数:7,代码来源:Enum.cs


示例13: Park

 public string Park(Car value)
 {
     if (IsFull()) return null;
     var parkingToken = ParkingToken.CreateParkingToken();
     garage.Add(parkingToken, value);
     return parkingToken;
 }
开发者ID:QMXGITHUB,项目名称:OOParkingSlot,代码行数:7,代码来源:Parkinglot.cs


示例14: DeleteCar

 public void DeleteCar(Car car)
 {
     FileDatabase fileDatabase = new FileDatabase("data");
     int i = _cars.FindIndex(x => car == x);
     _cars.RemoveAt(i);
     fileDatabase.SaveToDatabase(_cars.ToArray());
 }
开发者ID:ndiezel0,项目名称:Lesson2,代码行数:7,代码来源:AdminForCars.cs


示例15: DeadReckoningStrategy

 public DeadReckoningStrategy(Game game, Vector3 threshold)
 {
     this.Game = game;
     this.threshold = threshold;
     this.simulatedLocalCar = Car.CreateSimulatedCar(game);
     game.Components.Add(simulatedLocalCar);
 }
开发者ID:MintL,项目名称:datx02-rally,代码行数:7,代码来源:DeadReckoningStrategy.cs


示例16: Awake

    void Awake()
    {
        car = GetComponent<Car>();
        inv = GetComponentInChildren<CarInventory>();

        //neuen CameraController aufsetzen
        if(this.networkView.isMine || Network.connections.Length == 0){
            GameObject camObj;
            camObj = (GameObject)GameObject.Instantiate(cameraCtrlPrefab, car.transform.position, car.transform.rotation);

            cameraCtrl = camObj.GetComponent<CameraController>();

            cameraCtrl.targetCar = car;
            //erstes Element ist Motorhaubenkamera
            cameraCtrl.hoodCamera = additionalCameraPositions[0];
            //zweites Element ist Kofferraumkamera
            cameraCtrl.hoodCameraLookBack = additionalCameraPositions[1];

            GameObject hudObj;
            hudObj = (GameObject) GameObject.Instantiate(hudPrefab);

            hud = hudObj.GetComponent<HUD>();
            hud.cameraObject = camObj;
            setupHUD();
        }
    }
开发者ID:NoBudgetGames,项目名称:LastIgnition,代码行数:26,代码来源:PlayerInputController.cs


示例17: isDriverCar

 internal bool isDriverCar(Car car, DateTime date)
 {
     if ((date >= DateTime.Today) && (dateEnd == DateTime.Today))
         return car.ID == Car.ID && date >= dateBegin;
     else
         return car.ID == Car.ID && date >= dateBegin && date < dateEnd;
 }
开发者ID:NextStalker,项目名称:BBAuto,代码行数:7,代码来源:DriverCar.cs


示例18: Add

        public Car Add(Car car)
        {
            car.CarId = ++_carIdIndex;
            _cars.Add(car);

            return car;
        }
开发者ID:ItsDubC,项目名称:CarManager,代码行数:7,代码来源:DummyCarRepository.cs


示例19: Cars_Create

        public async Task<ActionResult> Cars_Create([DataSourceRequest] DataSourceRequest request, [Bind(Prefix = "models")]IEnumerable<CarViewModel> cars)
        {
            foreach (var car in cars)
            {
                if (car != null && ModelState.IsValid)
                {
                    var newCar = new Car { Name = car.Name };
                    if (car.CategoryId.HasValue)
                    {
                        newCar.CategoryId = car.CategoryId.Value;
                    }
                    else
                    {
                        var category = new Category { Name = car.CategoryName };
                        db.Entry(category).State = EntityState.Added;
                        newCar.Category = category;
                    }

                    db.Cars.Add(newCar);
                    await db.SaveChangesAsync();
                    car.Id = newCar.Id;

                }
            }
            await db.SaveChangesAsync();
            return Json(cars.ToDataSourceResult(request, ModelState));
        }
开发者ID:ignaciofuentes,项目名称:BatchEditDemoOptimized,代码行数:27,代码来源:HomeController.cs


示例20: ProcessCar

        private static void ProcessCar(IInventoryApi client, int i)
        {
            var car = new Car
            {
                Color = Color.Red.ToString(),
                Description = "Car #" + i,
                RentalPrice = 100.0m * (i + 1),
                Year = Convert.ToInt32(Math.Min(1997.0 + i, 2014))
            };

            var carId = client.UpdateCar(car).CarId;
            car.CarId = carId;

            var carFromDb = client.GetCar(carId);
            Debug.Assert(carFromDb.Equals(car));

            client.DeleteCar(carId);

            try
            {
                client.GetCar(carId);
            }
            catch (MessageException messageException)
            {
                Console.WriteLine(messageException.Message);
            }

            Log.WriteLine("Car {0} with carId: {1}", i, carId);
        }
开发者ID:yonglehou,项目名称:DistributedCommunicationDotNet,代码行数:29,代码来源:EndToEndTests.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# CarController类代码示例发布时间:2022-05-24
下一篇:
C# CaptureType类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap