« first day (2292 days earlier)      last day (2650 days later) » 

8:01 PM
Hey all ! I have an Abstract class Vehicle and a Car Class derived from it. I have created a constructor for Vehicle and a constructor for Car using : Base(Vehicle parameters). now when i try to make a new Car "Car StandardCar = new Car(...)" i want it to of course put arguements also in Vehicle.
how do i do that ?
 
Well you're going to need a Car constructor that also takes the params you want to pass to Vehicle
 
I am not sure I understand what you mean. Doesn't your constructor using Base(VehicleParams) do that?
Or are you not seeing properties defined in Vehicle represented in Car?
 
Car(Make make, Model model, int engineSize) : base(engineSize)
 
public Car(string myParam):base(myParam){}
 
    public Car(Vehicle i_Vehicle, int i_numOfDoors, color i_Color)  : base(i_Vehicle.ModelName,i_Vehicle.RegistrationNumber,i_Vehicle.PowerLeftPercentage, i_Vehicle.Engine)
 
8:05 PM
So you are passing a Vehicle in to a Car that is derived from a new instance of Vehicle?
 
i dont know im confused actually
I want the Car to have all its' base values
 
What would likely be best is having something like:
constructor call:
var myNewCar = newCar("Pontiac", "Firebird");

Class Declaration:
public class Car : Vehicle
{
public Car(string make, string model):Vehicle(DoorsEnum.4Door, EngineTypeEnum.Gas)
{
Make = make;
Model = model;
}
}
In that way Vehicle can be given standard values to make it a Car, and Car can set values that only cars would have.
If you for instance had a Ship class, that also derived from Vehicle, you would likely not set any doors. Perhaps you might have a property on the Vehicle abstract class that specifies what sub-class of vehicle it is (Land, Sea, Air, Space, etc)
 
Yeah but in this case Vehicle must have 4 Doors and use Gas
 
Are there expected to have any other classes derived from Vehicle?
 
Yeah, Bike and Truck
 
8:18 PM
What are they for example?
K
 
but still, i want to choose how many nums of doors i want once creating a new car Object
and not having it built-in
 
Sure.
You don't have to have every conceivable property populated in a constructor.
What the constructor is for is really just to get the class ready for use. Setting an identifier, initializing some thing, setting a couple of helpful properties.
So really, if there are any properties on Vehicle that will ALWAYS be set a specific way for Car, set those in that Base() call on the constructor.
Otherwise, either put them in as params in the Car constructor, or, just set them afterward in an initializing block or something.
 
do you know what version of ASP.NET uses master pages?
 
@erotavlas All asp.net webforms versions use MasterPages I think.
Certainly 2.x and up
 
oh ok, I was looking at MVC and it doean't contain anything resembling master pages
i.e. the latest version anyway
 
8:29 PM
@CodeWarrior then whats wrong with that ?
public Car(Vehicle i_Vehicle, int i_numOfDoors, color i_Color)
: base(i_Vehicle.ModelName,i_Vehicle.RegistrationNumber,i_Vehicle.PowerLeftPercentage, i_Vehicle.Engine)
 
In this case, you are passing in a Vehicle. I am just wondering why you don't cast your Vehicle as a Car.
 
@CodeWarrior isn't it calling the Vehicle parameters + Cars ones ?
 
@erotavlas Layout
 
@erotavlas - mvc 6 should still use a master layout page in Shared/_Layout.cshtml
 
8:31 PM
@SeventhSon yes the Layout.chtml was the closest
 
@CodeWarrior where ?
 
@ItayZaguri In the code that would call that Car constructor. Essentially what you can do is:

var myVehicle = new Vehicle(){A bunch of property settings here};
var myCar = (car)myVehicle;

I think.
That will give you an instance of Car that is backed by the original vehicle.
 
I've written the following code: https://gist.github.com/anonymous/49c31be93453744442f3869c77a3331f

And for some reason the StreamWriter / RedirectStandardInput does not seem to be working, but the StreamReader / RedirectStandardOuput works 1 time (the first time it is called)
Does anyone have any ideas?
 
Why are you using standard input as a writer and standard output as a reader? That seems odd.
 
@ItayZaguri Being an abstract class, where are you getting the Vehicle instance that you are passing in? From another car?
 
8:36 PM
@mikeTheLiar just following what the googles told me to do
 
Ah yes, the old "googling yourself off a bridge" method, classic.
 
From a Vehicle class @CodeWarrior
@CodeWarrior why cant i do it just like c++ ?
 
Yes, but since Vehicle is abstract, you cannot instantiate it.
 
@CodeWarrior I thought when you create a new Car it inherits all the properties of the base class, so can't you just assign them at that point (via the constructor)
i.e. the contrsuctor of car should have access to all the Vehicle base properties, no?
 
@mikeTheLiar - Or the everpopular, "youtube your hands off"
 
8:39 PM
Yup, Car will inherit all members from Vehicle. but outside of the Car constructor, you can't call the Vehicle constructor.
 
@mikeTheLiar indeed! I'll try using StandardInput directly i guess
 
I dont want to Instantiate Vehicle i want to Instantiate Car which is derived from Vehicle
No way i cant do that lol ..
 
too soon?
 
@ItayZaguri I know, but you are passing a Vehicle into the Car constructor. I am wondering where that Vehicle is coming from.
 
@TravisJ yes, youtube your hands off. Not any other tube, no sir.
 
8:40 PM
@CodeWarrior That what i was doing with c++
 
@ItayZaguri just inherit from Vehicle and then forget about Vehicle (just work with Car), Car should have everything Vehicle has + whatever Car has
 
Hmm. Can C++ abstracts be instantiated explicitly? I can't remember.
Been like a decade since I C++ed.
 
Nope, but in c++ i used to call the abstract base C'tor when i make a new object
as a part of initiating its child
 
Indeed. What @erotavlas said. The only time that you should have to refer to Vehicle is if you want to check to see if objects are of that base type (like you have a collection of Vehicles or something), or if you want to set standard base properties at Car construction time.
 
8:43 PM
@TravisJ something something knife game song
 
@erotavlas so youre saying Vehicle shouldnt have a c'tor ?
 
The only problem is that you can't instance a vehicle and pass it to car since you can't instance an abstract class.
 
@mikeTheLiar still doesnt work. at least the code is slightly less weird looking now
 
@KendallFrey - creepy
 
8:52 PM
hello
when i execute a sql query in managementstudio i get the result within a few seconds but when i execute exactly the same query in linq2sql, it gets a database timeout. how can that happen?
i used the datacontext.Log to copy and paste the generated sql query from linq so the queries are indentical
 
but you still made a c'tor inside the Car class which takes SPECIFIC values @CodeWarrior
 
And I also provided a constructor that takes no values. If you want, you could instead have a constructor that takes no values AND calls the base constructor with no params. You can do whatever you want, except, you cannot instance a Vehicle and pass it in there UNLESS you are actually passing in a Vehicle that is actaully a Car, Truck, or Bike.
Cars, Trucks, and Bikes are also Vehicles, and so in that case, you CAN pass those as arguments. I havent tried that, but I would imagine that it would work.
but you can do var myVehicle = new Vehicle(); to get something that you can pass into that Car constructor.
 
i solved it now with dataContext.ExecuteQuery<T>("SELECT statement") but i still would like to know what caused this issue :|
 
9:45 PM
any one have ideas?
http://stackoverflow.com/questions/41838955/c-sharp-interacting-with-cli-process-standard-input-not-working/41839451#41839451
 
@Michael I reckon it's because you're reading the entirety of the output before sending any input. I don't think ReadLine returns null if it's just idle.
 
@KendallFrey I've determined that what seems to be happening. But I don't know how to fix it.

If I set a breakpoint after process.StandardInput.WriteLine("connect vpn.service.domain.com");
The breakpoint is never hit and my WinForm becomes active. (does that mean the process is just exiting on its own? the process remains active in TaskManager though).
 
But what happens if you put a breakpoint immediately before it?
 
It gets hit before I call it
same thing happens during the very last process.StandardOutput.ReadLine();
@KendallFrey any idea?
 
not really
I'm not even sure what you're describing
 
10:03 PM
@KendallFrey
I have a Winform App.
In the code behind I try to interact with a CLI.

If I have the following 2 lines of code with a breakpoint on the 2nd line. The breakpoint will never get hit it. The code behind just stops processing and my winform obtains focus.

Line1: process.StandardInput.WriteLine("some command");
Line2: var a = 1;
 
11:02 PM
@KendallFrey hahaha Snollebollekes is from my 'Provincie'
 
saw this, thought I would share... when arguing on meta gets your account deleted:
 

« first day (2292 days earlier)      last day (2650 days later) »