« first day (2290 days earlier)      last day (2662 days later) » 

1:56 AM
@AdanRamirez I am able to run that code without problem.
 
2:13 AM
Fixed the code, replaced downloaddata with download string
 
2:42 AM
Hey! Whats the best alternative for multi-inheritance in c#?
 
@ItayZaguri That depends entirely on what you're trying to achieve
 
2:59 AM
the same thing we were talking earlier - the Fuel/Electric vehicles.
my lecturer said that interface was not needed here
 
 
2 hours later…
4:48 AM
@ItayZaguri Typical the alternative to multi-inheritance is to implement multiple interfaces. Or you could do a combination of inheriting some base class and implement another interface. If that solution is not needed, then you may need to rethink the problem.
For example, if there's no need to be able to work with a certain set of different types generically, then maybe it doesn't need to have the inheritance structure to allow that. Or maybe you can solve something with having different method overloads that handle each type instead of having to handle a single base class.
 
5:36 AM
i was gona say interface
 
 
5 hours later…
10:50 AM
hello
 
 
3 hours later…
2:10 PM
guys, I have a problem - I have a c# project which works fine on my working notebook, but I copied it to my home computer and now I have "Could not load file or assembly" errors
what is the cause of this?
 
Did you copy over all the assemblies it depends on?
Do you have assembly references other than what's in the .net framework?
 
yes, but I have it all
I used DependencyWalker and it says I have missing files like API-MS-WIN-CORE-APIQUERY-L1-1-0.DLL
no idea what those files are yet
 
Hmm looks like .net core which is too new for me, I haven't really gotten into it yet
 
it's winforms project:P
I don't get it, the same project runs fine on another computer
only thing different is visual studio - it's not working on 2015
 
3:00 PM
@JeffBridgman i was asked to make classes for electric car & bike and classes for Fuel using car, bike and Truck . i created a Vehicle class and Car,Bike,Trunk derived of it. then Standard Car and Electric Car derived of Car and same with Bike. Truck has no 'childs'.
Now i dont know where to put the Electric and Using Fuel elements without double coding
also using no interfaces :\
 
 
2 hours later…
5:03 PM
Hey, does anyone here understand constrained execution regions?
I've tried to find out more about them, but the documentation is pretty poor and SO doesn't seem to have a lot of info on it.
Hello
 
Weekend, room is usually dead
+ I've been writing C# for eight years and I dunno what a constrained execution region is, never heard of it
 
5:24 PM
lol
It seems to be some way to ensure finalizers get run
or to ensure that some code can run and some cant
 
5:38 PM
@ItayZaguri Can't you just have a FuelType enum field/property on the Vehicle base class that has values Electric, Gas, None or something like that?
 
What if the vehicle has no fuel?
like a bike
huh
That does seem like the best solution
you'd run into trouble with hybrids though
maybe give the FuelType a FlagsAttribute
You could also use some sort of strategy pattern for Fuel.
On an unrelated note, does anyone else wish there was a way to easily create awaitable objects?
 
Task.Run?
That's fairly easy
 
no, I meant like a class that's awaitable
 
Well you can implement IAwaitable
 
I was doing work with encapsulating overlapped IO. Got it to work in a nice, clean way, but it's still kind of akward to use
 
5:46 PM
I think? I've never needed to
 
lol
I honestly don't know how to do that.
maybe just expose the TCS for the class?
 
3
Q: AsyncCTP: Creating a class that is IAwaitable

sgtzI found myself wanting to implement an IAwaitable class (something that implements asynchronous calls without blocking threads). I've got the most recent version of AsyncCTP installed, and the compiler is saying that I need an IsCompleted() member. Okay, so the CTP preview has moved on a litt...

looks easy enough
 
damn, that was fast.
so it does
 
Fastest Googler in the West
 
lol
I'm usually pretty good. I kept hitting stuff that was like "You have to capture the execution context and then do all this other stuff"
Thanks. And yeah, it's a weird thing to do
the issue really is that doing overlapped native IO is....gross looking
there's a LOT of boilerplate code that needs to be done
 
5:50 PM
Do the asynchronous filesystem APIs not already do what you want?
From System.IO?
 
and if you do it using closures over a TCS it's...well it's absolute shit to read
nope
They explicitly block doing raw disk access
at least they do according to the reference source
 
What are you building, Stark?
 
lol
I WAS building something to read from a custom file system
that the OS doesn't recognize
 
 
lol
I ended up making a nice API that wraps around ANY overlapped method
and exposes it as a task
but...yeah...no...it's ugly
and I'm still not sure whether it's correct, mainly because the documentation about Overlapped is shitty as hell
...what's wrong with batmans eye?
it looks....bubbly
btw, the thing works great
Was hitting almost the maximum transfer speed for USB 3.0
so....no problems there, really
well no
for the SD card I was using
....
IAwaitable is only in the Interactive extensions
Sad Trumpet
 
5:57 PM
Is it true you can await anything that has a method called GetAwaiter that returns an awaiter? Like I say I've never needed to do this
 
I doubt it.
 
Memory hazy, I seem to remember several levels of "Well that's not quite true..."
 
That's be a really weird "magic" feature.
 
Compiler dude.
Compiler do wtf it want
 
Yeah, but..you know...interfaces
 
5:59 PM
 
compiler should link behavior like that to an interface, not to some random-ass method name
 
damn
 
smashes his keyboard
ANCIENT EGYPTIANS DID NOT USE TREBUCHES TO LAUNCH GODDAMN GLIDERS
 
Well why the hell not?
Slackers
 
no no
more angry at the people, not the egyptians
I watched like....one episode of that with my friend
thought I was gonna have a stroke
 
6:02 PM
I think I am aware of it, sounds like nonsense
 
So Tom, you try targeting .NET Standard yet?
 
6:33 PM
bleh. This is not a good technology yet.
 
Nope
2new4me
 
It looks like it's gonna be nice though
though...I kinda thought .NET Framework was supposed to be the minimum class library
 
7:12 PM
@JeffBridgman Nope, because every Fuel using car should have extra variables such as GasType,GasTankQuantity and a FillTank Method, and every electric car should have variables like batteryTime and ChargeBattery Method
 
7:43 PM
Hola chickitas
anyone good with sequence diagrams?
 
8:20 PM
@ItayZaguri You can either use extension methods off your enum, or you can use a strategy pattern
so you have an abstract Fuel class with the methods and properties you need, and then create subclasses of that.
You should also abstract away analogous operations. "GasTankQuantity" and "BatteryTime" are expressing the same type of value, and "FillTank" and "ChargeBattery" do essentially the same thing.
 
why does uriencode has 15 versions in C#
 
You could have your Fuel class have a "Remaining" property and a "Refill" method instead.
@misha130 what?
 
309
A: URL Encoding using C#

Simon TewsiI've been experimenting with the various methods .NET provide for URL encoding. Perhaps the following table will be useful (as output from a test app I wrote): Unencoded UrlEncoded UrlEncodedUnicode UrlPathEncoded EscapedDataString EscapedUriString HtmlEncoded HtmlAttributeEncoded HexEscaped A ...

 
Unicode has a couple different versions in every language because there are several different standards.
 
Unencoded UrlEncoded UrlEncodedUnicode UrlPathEncoded EscapedDataString EscapedUriString HtmlEncoded HtmlAttributeEncoded HexEscaped
 
8:25 PM
yeah....?
Each one of those has a different purpouse
 
small differences though
well obviously you are right but all these libraries are microsoft
so they went in 15 different libraries and wrote 15 different methods
 
How are they 15 different libraries? They're all for formatting data so that different standards can understand them
 
their locations
httputility
webutility
I am just saying instead of centralizing
its a mess
 
Seems fine to me. Grouping by usage.
Http needs different formatting than some web requests.
17
Q: WebUtility.HtmlDecode vs HttpUtilty.HtmlDecode

zi3guwI was using WebUtilty.HtmlDecode to decode HTML. It turns out that it doesn't decode properly, for example, – is supposed to decode to a "–" character, but WebUtilty.HtmlDecode does not decode it. HttpUtilty.HtmlDecode, however, does. Debug.WriteLine(WebUtility.HtmlDecode("–")); Debu...

 
the answer I posted did demonstrate the difference between webutility & httputility
well seems the rest of them are legacy through out the ages
 
8:34 PM
If you read all the answers, it seems obvious that they're not legacy, they're different use cases
specifically, one of them is contained in System.dll instead of System.Web.dll
WebUtility, the one in System.dll, has fewer, less flexible methods, and doesnt require you to load a bunch of shit from System.Web.dll if you don't need it
 
some of the 4.0 .net
I mean
 
I don't know what you mean by "Some of the 4.0 .net"
 
yes its not "legacy"
if you read the answers you'll see some of them refer to how 4.0 .net had a different way of encoding
5
A: Uri.EscapeUriString with square braces

Matthew WatsonThis changed between .Net 4 and .Net 4.5, which you can verify by retargeting the framework version to .Net 4 and running the test program. .Net 4 -> outputs "%5B" .net 4.5 (or later) -> outputs "[" This is mentioned here: Application Compatibility in the .NET Framework 4.5 under the section f...

rather than actual legacy it supports a different RFC by version
 
I think I've lost your point/question.
.NET 4 Uri.EscapeUriString had different behavior than 4.5. What does that have to do with either of the two classes before?
 
8:49 PM
they are of the same series
I didnt talk about httptutility/webutility explicitly
I just used them as an example
 
They do different things with some overlap. yes
Woooow....async DOES use just...a random function
weird
 
9:14 PM
@ginkner the thing is that the Standard / Electric Car classes, Standard / Electric Bike class and Trunk class are already derived from the class Vehicle and Multi-Inheritance is not allowed in c#
 
@ItayZaguri So just add the Fuel property to the vehicle class?
 
but then a electric Car would have fuel properties
 
yes. The electric car uses electric fuel
all vehicles use fuel
 
the methods FillGas and ChargeBattery are different a bit because FillGas has a parameter FuelType
so i cant use the same method for both
 
and I'm saying it shouldnt
you shouldn't have two methods
 
9:19 PM
I shouldn't have one method thats for sure
 
honestly I would implement IElectrical and IFuelable
 
That's rediculious
hold on
 
thats what i was thinking, but my lecturer said it didnt need interfaces
 
so you are saying the child class should always have the same methods as the parent?
 
Vehicle - > Car,Bike,Trunk
Car - > Standard Car , Electric Car
Bike - > Standard Bike, Electric Bike
+ somehow make ONLY standards and Trunk have some Fuel properities and ONLY electic Bike and car have Electric properties
 
9:22 PM
Creating Example
 
I tried different inheritance :
Vehicle - > Fuel, Electric
Fuel - > Standard Car, Standard Bike , Trunk
Electric -> Electric Bike , Electric Car
but then i have to double code
 
that doesnt make sense
a fuel isnt a vehicle
 
ok so name it "FuelVehicle" or something like that
it still not good
its*
 
why is it double code actually
just abstract it in FuelVehicle
and implement it in the cars
 
9:31 PM
throw exception on standard bike I guess
 
you're inheritance structure is wonky, because an electric car really isn't a different kind of car. It's just a car that uses a specific kind of fuel.
 
hey blame the university professor
 
i lacked of info : every Car has one of 4 Colors [ black white silver Red] and an integer NumOfDoors
every Bike has string LicenseTYpe and integer EngineVolume
so it is double coding
 
maybe you want to use pastebin to actually show the problem. You might get shit though, cause this isn't a "Do your homework for you" kind of place
 
thanks for the code
i know, and im not expecting anyone to do my HW. but i'm stuck like 2 days and really want to keep going
 
9:37 PM
paste the full problem on pastebin.
or possibly Fuel->Electric,Standard,None.
you could also use interfaces
StandardCar:IStandardFuel,ICar
but yeah, you're either gonna have to create a couple different heirarchies, or you're gonna have to do some copy-pasting
 
@ginkner
this is how i did it, now it looks like that i created classes for each Normal\Electric Car\Bike for nothing, but there's the Fuel\Electric properties\method that separate them
 
10:16 PM
so you CANT change the classes that have already been filled in?
 
i can change everything
 
then don't do it this way
you make your code less flexible and harder to understand
@ItayZaguri you're trying to fit a square peg into a round hole
 
so you're saying the whole inheritance structure is not good ?
you say that because I created a specific class for each kind of car ?
 
I'm saying YOUR inheritance structure isn't good because you're trying to inherit several behavior types at once
 
\bike
like what ?
 
10:29 PM
Your mental model is "a CAR IS A Vechical AND IS electric"
your mental model should/could be "a car IS A Vehicle WITH some kind of FUEL AND WITH a licence type.
 
*numberOfDoors , licenseType is for a bike
 
a bike IS A VEHICLE that HAS A fuel and HAS A number of doors and HAS A licencetype.
inheritance indicates an IS A relationship
composition indicates a HAS A relationship
 
anyway my mental is "a standard car IS a car which is a Vehicle WITH some kind of fuel"
 
then your fuel should be a property
WITH and HAS A are the same kind of relationship
 
then i have to double code the properties inside Standard Car, Standard Bike and a Truck
 
10:35 PM
no you dont? which properties would you need to change?
 
where do you think these properties should be in ?
 
which properties are you talking about?
 
Fuel\Electric
 
There's only ONE property
"Fuel"
 
i misunderstand something i guess
 
10:38 PM
look at the example I gave you
there's ONE fuel property
 
the example uses interfaces
 
so? Interfaces are fine
 
not for my lecturer lol
 
in this case you could turn the interface into an abstract class
the only real difference is that abstract classes can have some implementation, whereas interfaces cant
 
but you cant multi-inheritance
 
10:39 PM
and you can only inherit one class, obviously
you don't need to
 
so what class inherit Fuel ?
 
ahhhh
so you just use the Fuel class from inside the Vehicle class
 
yup
composition
not inheritance
 
because it isnt literally a FUELTYPE it just uses Fuel
amazing thank you !
by the way, my inheritance structure is not that bad, you did almost the same thing besides Fuel classes and composition
 
10:54 PM
It's a little weird that you're inheriting that much at all. You'd do just as well to leave it at "Car" at this point, since you can just flop in whatever IFuel you want
 
11:30 PM
but Car has IFuel type inside it, how can i access either GasFuel or ElectricFuel ? polymorphism ?
 
yup. all you need is the methods provided by IFuel.
Car a=ElectricCar
a.Fuel.Refill()
a.Fuel.Level
since you don't seem to need to deal with vehicles with more than one fuel type, it shouldn't be an issue
 
11:48 PM
if i want a new Car object 'a' to be an electric Car then i have to make an IFuel object inside which points to ElectricFuel class
 
new Car(new ElectricFuel())
 

« first day (2290 days earlier)      last day (2662 days later) »