Official Everybody Edits Forums

Do you think I could just leave this part blank and it'd be okay? We're just going to replace the whole thing with a header image anyway, right?

You are not logged in.

#1 2017-08-08 04:34:08

italkalotfromee
Member
Joined: 2015-05-08
Posts: 117

CSharp Help please!

Directions:
Fill in the blanks to instantiate an object of the class Cat, passing to the constructor the value 12. Then call Meow method for that object.

Cat c = ___ Cat(__);
__Meow();

Can someone help me fill in the blanks?


FluxBB bbcode test

Offline

#2 2017-08-08 05:14:39

lrussell
Member
From: Saturn's Titan
Joined: 2015-02-15
Posts: 843
Website

Re: CSharp Help please!

Cat c = new Cat(12);
c.Meow();

Offline

Wooted by:

#3 2017-08-08 06:37:16

XxAtillaxX
Member
Joined: 2015-11-28
Posts: 4,202

Re: CSharp Help please!

lrussell wrote:
Cat c = new Cat(12);
c.Meow();

why nobody use var :'(


signature.png
*u stinky*

Offline

Wooted by: (2)

#4 2017-08-08 06:50:23, last edited by showpath (2017-08-08 06:51:04)

showpath
Member
Joined: 2015-02-16
Posts: 106

Re: CSharp Help please!

XxAtillaxX wrote:
lrussell wrote:
Cat c = new Cat(12);
c.Meow();

why nobody use var :'(

var cat = new Cat(0xc);
cat.Meow();

Complete variable names are always good practice.

Offline

Wooted by:

#5 2017-08-08 07:15:14

Gosha
Member
From: Russia
Joined: 2015-03-15
Posts: 6,211

Re: CSharp Help please!

while(true)
   cat.Meow();

hehehe

Offline

Wooted by: (3)

#6 2017-08-08 07:44:55

Anatoly
Guest

Re: CSharp Help please!

Gosha wrote:
while(true)
   cat.Meow();

hehehe

while (true) {
    Thread.Sleep(100);
    _connection.Send("say", "/kick gosha Meow")
    Thread.Sleep(100);
    _connection.Send("say", "/forgive gosha")
}

I learn fast //forums.everybodyedits.com/img/smilies/wink

#7 2017-08-08 12:03:20

Vinyl Melody
Formerly BananaMilkShake
Joined: 2016-06-19
Posts: 616

Re: CSharp Help please!

If you're using cat once.

(new Cat(12)).Meow();

---

AnatolyEE wrote:
Gosha wrote:
while(true)
   cat.Meow();

hehehe

while (true) {
    Thread.Sleep(100);
    _connection.Send("say", "/kick gosha Meow")
    Thread.Sleep(100);
    _connection.Send("say", "/forgive gosha")
}

I learn fast //forums.everybodyedits.com/img/smilies/wink

Random rng = new Random();
while(true) {
    con.Send("say", "/teleport AnatolyEE {0} {1}".MelodyFormat(rng.Next(0,worldX),rng.Next(0,worldY))); // I'm too poor to use C# 6 so I just did this stupid Extension Method
    await Task.Delay(20);
}

cb0de83627.png
Thanks to: Ernesdo (Current Avatar), Zoey2070 (Signature)

Very inactive, maybe in the future, idk.

Offline

#8 2017-08-08 12:28:34

Gosha
Member
From: Russia
Joined: 2015-03-15
Posts: 6,211

Re: CSharp Help please!

AnatolyEE wrote:
Gosha wrote:
while(true)
   cat.Meow();

hehehe

while (true) {
    Thread.Sleep(100);
    _connection.Send("say", "/kick gosha Meow")
    Thread.Sleep(100);
    _connection.Send("say", "/forgive gosha")
}

I learn fast //forums.everybodyedits.com/img/smilies/wink

i just won't join again
roasted

Offline

Wooted by:

#9 2017-08-08 13:23:15

den3107
Member
From: Netherlands
Joined: 2015-04-24
Posts: 1,025

Re: CSharp Help please!

showpath wrote:
XxAtillaxX wrote:
lrussell wrote:
Cat c = new Cat(12);
c.Meow();

why nobody use var :'(

var cat = new Cat(0xc);
cat.Meow();

Complete variable names are always good practice.

For things where the return type is explicit (like when instantiating) I actually generally see the use of var being used since... As I said: it's explicit, obvious.

Myself I still prefer explicit variable type declaration. When I'm not sure what type the variable was, I look at the declaration, not where it's value is actually set (since generally that's in a ton of places that don't have any obvious position), meaning that if I'd put var there, I'd still have to keep looking around.
That's also why I dislike JavaScript to a degree, since I like to know and control exactly what type the variable is from the very start.

Offline

#10 2017-08-08 13:25:44

Vinyl Melody
Formerly BananaMilkShake
Joined: 2016-06-19
Posts: 616

Re: CSharp Help please!

not worrying about type declaration is why I love lua.


cb0de83627.png
Thanks to: Ernesdo (Current Avatar), Zoey2070 (Signature)

Very inactive, maybe in the future, idk.

Offline

#11 2017-08-08 13:38:08, last edited by italkalotfromee (2017-08-08 13:40:02)

italkalotfromee
Member
Joined: 2015-05-08
Posts: 117

Re: CSharp Help please!

Directions
Fill in the blanks to overload the minus operator for the T class:

public ___ T ____ - (T a, T b)
{
  T res = new T(a.num - b.num); 
  ____res;
}

There's another. //forums.everybodyedits.com/img/smilies/smile

Also what is "0xc?"

var cat = new Cat(0xc);
cat.Meow();

FluxBB bbcode test

Offline

#12 2017-08-08 13:53:36

Gosha
Member
From: Russia
Joined: 2015-03-15
Posts: 6,211

Re: CSharp Help please!

0xc is a hex value

Decimal numbers are
0 1 2 3 4 5 6 7 8 9

Hex values are
0 1 2 3 4 5 6 7 8 9 a(10) b(11) c(12) d(13) e(14) f(15)

C is equal to 12 in decimal.
So 0xC means 12

Offline

Wooted by:

#13 2017-08-08 16:46:36

hummerz5
Member
From: wait I'm not a secret mod huh
Joined: 2015-08-10
Posts: 5,853

Re: CSharp Help please!

this smells a lot like homework, are you sure you want to be asking?

Offline

#14 2017-08-08 17:00:03, last edited by XxAtillaxX (2017-08-08 17:01:02)

XxAtillaxX
Member
Joined: 2015-11-28
Posts: 4,202

Re: CSharp Help please!

I'd highly recommend figuring these things out yourself through actual practice, you won't learn very much by getting the answers handed to you.
In any event, having the answers directly provided to you is fine as long as you're acknowledging that memory alone won't help you very far in the long run.

public override T operator - (T a, T b)
{
  T res = new T(a.num - b.num); 
  return res;
}

or, if they accept less verbose examples,

public override T operator - (T first, T second)
{
  return new T(first.num - second.num);
}

also before anyone comments, this could be done but eh, it seems dodgy

public override T operator - (T first, T second) =>
  return new T(first.num - second.num);

signature.png
*u stinky*

Offline

#15 2017-08-09 01:08:25

den3107
Member
From: Netherlands
Joined: 2015-04-24
Posts: 1,025

Re: CSharp Help please!

Off topic:

XxAtillaxX wrote:
public override T operator - (T first, T second) =>
  return new T(first.num - second.num);

Actually got a classmate that, once he discovered Linq and Lambda expressions, he tried to pump his code full of it.
He's the kind of dude that find something cool, throws away everything he's learned before, and tries to do everything with "this awesome thing I just discovered".

Terribly annoying...

Offline

#16 2017-08-10 13:40:20

hummerz5
Member
From: wait I'm not a secret mod huh
Joined: 2015-08-10
Posts: 5,853

Re: CSharp Help please!

the topic has essentially snuffed out but remember these sorts of discussions aren't EE-related so they go to Off-Topic

Offline

#17 2017-08-10 16:35:51

Anatoly
Guest

Re: CSharp Help please!

Vinyl Melody wrote:

If you're using cat once.

(new Cat(12)).Meow();

---

AnatolyEE wrote:
Gosha wrote:
while(true)
   cat.Meow();

hehehe

while (true) {
    Thread.Sleep(100);
    _connection.Send("say", "/kick gosha Meow")
    Thread.Sleep(100);
    _connection.Send("say", "/forgive gosha")
}

I learn fast //forums.everybodyedits.com/img/smilies/wink

Random rng = new Random();
while(true) {
    con.Send("say", "/teleport AnatolyEE {0} {1}".MelodyFormat(rng.Next(0,worldX),rng.Next(0,worldY))); // I'm too poor to use C# 6 so I just did this stupid Extension Method
    await Task.Delay(20);
}

worldX and worldY is null, so it will return an error.

#18 2017-08-10 23:46:30

Kikikan
Member
From: Hungary
Joined: 2015-08-10
Posts: 204

Re: CSharp Help please!

AnatolyEE wrote:
Vinyl Melody wrote:

If you're using cat once.

(new Cat(12)).Meow();

---

AnatolyEE wrote:
Gosha wrote:
while(true)
   cat.Meow();

hehehe

while (true) {
    Thread.Sleep(100);
    _connection.Send("say", "/kick gosha Meow")
    Thread.Sleep(100);
    _connection.Send("say", "/forgive gosha")
}

I learn fast //forums.everybodyedits.com/img/smilies/wink

Random rng = new Random();
while(true) {
    con.Send("say", "/teleport AnatolyEE {0} {1}".MelodyFormat(rng.Next(0,worldX),rng.Next(0,worldY))); // I'm too poor to use C# 6 so I just did this stupid Extension Method
    await Task.Delay(20);
}

worldX and worldY is null, so it will return an error.

then set them to something

Offline

#19 2017-08-11 04:48:01

Hannah32
Member
Joined: 2015-12-10
Posts: 104

Re: CSharp Help please!

D flat mate

Offline

Wooted by:
Hannah321502423281672332

Board footer

Powered by FluxBB

[ Started around 1732964318.4692 - Generated in 0.068 seconds, 10 queries executed - Memory usage: 1.65 MiB (Peak: 1.86 MiB) ]