« first day (1916 days earlier)      last day (3035 days later) » 

1:00 PM
I am trying to use convert to string but I can't fetch the var from my class.
 
Then you can just pass it to Show() and it will be converted
 
private void button1_Click(object sender, EventArgs e)
{
clsDestination.Hours(); // my class name where the variable hours is located
MessageBox.Show();
}
 
Return the calculated value from Hours() instead. At the moment you're calculating a value, then throwing it away when Hours() completes
 
public static void Hours() {

var length = 30;

var speed = 80;
var hours = length / speed;

return;
}
That is my class @TomW
 
No, that is your method. That's not a class
 
1:05 PM
and that is my method Hours(){}
 
It's a member of a class.
OK. Return hours
 
@mark Look at implementing public properties
 
Are you teaching programming 101 @TomW?
 
@RoelvanUden apparently so, even after saying I wasn't going to
 
morning
 
1:06 PM
I will pay @TomW 5bucks someday if he help me to fix this.
hehe
 
You do realize our commercial tariff is ~4 euro/minute, right? ;-)
 
Error 1 Since 'WindowsForm.clsDestination.Hours()' returns void, a return keyword must not be followed by an object expression
if I use the return hours;
 
Then don't return void
 
@mark Have you begun learning about programming as a hobby or are you a fresh student entering a programming course?
 
You should be able to work out what is wrong, I'm not going to tell you this one
 
1:08 PM
Rubber duck debugging is an informal term used in software engineering for a method of debugging code. The name is a reference to a story in the book The Pragmatic Programmer in which a programmer would carry around a rubber duck and debug their code by forcing themselves to explain it, line-by-line, to the duck. Many other terms exist for this technique, often involving different inanimate objects. Many programmers have had the experience of explaining a programming problem to someone else, possibly even to someone who knows nothing about programming, and then hitting upon the solution in the...
 
@RoelvanUden I am starting to learn the programming and building some passion on it.
 
Yes, as a hobby, or as a student, is what I was asking.
 
@RoelvanUden as a student. But I am not studying in real school. My own only and through some tutorials and from other professionals like you guys.
 
hahaha
Almost as diffuse answer as I expected :D
Mark = Politician
 
hihihi
 
1:11 PM
So, as a hobby. Thanks for clearing that up. Have you begun on the PluralSight beginner courses?
 
so what now should I do to show the variable hours in my message box?
 
How can I profile in VS2015 how much byte a simple int a = 20; code allocates? I mean which view will show it to me?
 
hihi @JakobMillah :D
so @RoelvanUden what should I do now to show it in my messagebox?
 
@mark I've shown you everything you need. Put it together, you can work this out yourself
 
@mark I don't know. I don't know programming. I'm just here to say I'm geeky.
2
 
1:16 PM
That nose is growing pretty large, Pinoccio
;)
 
@TomW I will let you know guys if I am done fixing this. hehe @RoelvanUden Oh... hehe :D Well, I will thank you guys! hehe Have a good day!
 
var goodDayMessage = "Have a good day, @mark!";
MessageBox.Show(goodDayMessage);
 
morning
 
Mörning
 
Morgen
 
1:26 PM
Woke up just as broke as I was yesterday
 
Is using "var" in c# bad practice? or is it ok?
 
o/
 
as long as you know what Var is going to be
 
@JakobMillah its fine
 
@JakobMillah could you explain why it might be bad practice?
 
1:27 PM
I don't know? Takes more time maybe? Readability etc etc
 
you know what the type is going to be, or can infer
 
if you're worried about readability you should make your methods shorter :)
 
@JakobMillah the only con is readability maybe... but some would say that it even helps with readability to a point
 
string s = "t"; and var s = "t"; basically compiles to the same thing
 
Alright
Does it work on objects as well?
 
1:28 PM
@JakobMillah yes
 
wtf
 
{}
 
@JakobMillah it will yell at you when it doesnt work
 
And in what cases doesn't it?
 
it doesn't work when your code doesn't compile
that's it
 
1:29 PM
If you don't use var when you can, you should be shot. If you survive, you should be shot again.
 
I don't know how to react to this madness
 
when the type is ambiguous, such as when you declare a class-wide variable
you can't do
public class X {
   var y;

   public X() {
      y = 1;
   }

}
 
╔═════╦════════╦══════════╦
║ ID ║ Name ║ RandomID ║
╠═════╬════════╬══════════╬
║ 1 ║ a ║ 3 ║
║ 2 ║ b ║ 2 ║
║ 3 ║ c ║ 1 ║
╚═════╩════════╩══════════╩

I have this result returning from a BIG select query
I need to add another column, which will be "RandomName"
but I have no idea how can I do this
 
I've never used var in c#. Only for quick testing, then changed to proper type
 
I always use var unless I can't (return type, parameter type, property type)
 
1:30 PM
That is a really fancy ascii graphic
Nice work
 
@JakobMillah why not, it's pretty awesome when you have to change that type
 
That is a a nice Graphic in the chat
 
It sure is.. I always thought it would take longer etc. No teacher told me that var is something good.
 
@JakobMillah well, what do they know anyway
 
@JakobMillah its not really a matter of being "good" its just a nice little option, perk
 
1:31 PM
@JakobMillah what do you expect from it ? milk a cow ? lol it has it's benefits and bad points like everything else :P
 
My teachers have been really sucky sucky, so not much
 
I hate the education system
 
Well it's good for lazy men
And I am lazy
 
@JakobMillah sucky sucky like thailand?
 
No, Sweden
And that's bad
 
1:33 PM
Useful if you want a variable that's upcast from the return type of an expression i.e. Base foo = new Derived(); // class Derived : Base
 
i thought swedish girls were hot
 
The grills are very hot yes. But the educations not so much
Depending completely on which Uni. Only a few really good
 
Which is peculiar. People built for surviving arctic winters don't immediately spring to mind as attractive.
 
Well, the wildling in GoT can be pretty sexy. So that's pretty much valid
 
@TomW well when you get to the stage where you wear bikini's and uggs in -10 degree weather
maybe you're past the unattractive stage
 
1:36 PM
Sorry about always talking about EF lately, just trying to understand it. This is my first week really using it.

But i was concerned about layers of separation. The Context itself sort of acts like a Half and Half business layer and Data Access layer, right?

So if I have a winform with a datagridview, and I want to populate the datagridview, In the code behind Its perfectly fine to do a Using(context){ context.Object.getData();} right?
 
@Michael do you know what a repository pattern is?
 
@Failsafe Yes, but I dont think we are going to use that with our project
 
hii
can any one help me with this stackoverflow.com/questions/34791015/…
 
@Michael That's pretty much what EF is
 
@Failsafe true enough. Look at any town centre on a Saturday night and it's clear young women have no perception of cold
 
1:37 PM
all it does is map DB tables to models
 
@Failsafe Right.. some people put another repository/ unitofwork layer onto it
@Failsafe So it is fine to put a Using(context){} in the codebehind?
 
@Michael that's what everybody does
 
because I have to get my objects to the UI somehow..
 
@TomW Well they face it the morning after.
 
@Failsafe okay. Im trying to understand the layers of separation better
 
1:39 PM
using (Entities context = new Entities()){
MyTable query = (from c in context.MyTable
select c);

}
That's the same as doing "select * from Mytable"
then doing a datareader
then looping through reader rows
 
@Failsafe and its fine to have a bunch of the using statements throughout the UI and object classes in order to get data to and from them
 
are you using mvc?
because if so you can use a model type of MyTable as enumerable
and return the table model to the view
 
How to check to see if textBox1 has the specified string upon button click?
 
im not really sure what the standard is but i see a lot of people doing it
@kolton textbox1.Text
 
    @Failsafe winforms. So like if I have a person class, which has a SaveChanges() method I can do :

    SaveChanges(){
     using (Entities context = new Entities()){
      context.Contacts.Add(this);
}
    }
 
1:42 PM
in your textbox1_OnClick event
 
@Failsafe But it needs to search a sentence for a specific word.

For example:

User types: Today was a fantastic day.

The specified string is day and when the user clicks the button it shows on the label night
 
using (Entities context = new Entities()){
context.Entry(new Contacts() {myparams}).State = EntityState.Add;
context.SaveChanges();
}
 
And then the opposite for the specified string night
 
@kolton textBox1.text.Contains("day");
 
@kolton ^
 
1:45 PM
Tried it, it doesn't work
 
paste your code in here
 
pastebin.org if its' long
 
K one sec. I deleted it.
 
@Failsafe what if something changes with my object for an update.. and I dont want to use context.Entry(c).State = EntityState.Modified;
 
@Michael you need to use that
then context.SaveChanges() after the modified
that's how the entity knows that the model has changed
with those entity states
 
1:48 PM
@Michael since Web is a disconnected stateless, you need to notify that the entity changed
 
my IT desk blocks pastebin
for some reason*
 
boo to them
 
lol
no pastebin though
gist is fine
 
@kolton are you putting 'day' in the textbox?
 
1:49 PM
I got it to work
 
it is CaSe Sensitive
 
@Failsafe okay. So right now I actually have all this extracted out to a static dataAccess class:

pastebin.com/1BwHCR0z

and then in a Contact Class I might call:

 public bool SaveChanges()
        {
            bool result = false;

            if (this.Id.HasValue) //Update
            {
                int returnValue = ContactDataAccess.UpdateContact(this);
                result = (returnValue > 0) ? true : false;
            }
            else //Insert
            {
                int? returnValue = ContactDataAccess.InsertContact(this);
 
When I had my code before, I didn't do else if
 
can any one help me with this stackoverflow.com/questions/34791015/…
 
@Failsafe It seems exactly the same as putting the usings directly in the objects themselves. Same with the UI
 
1:50 PM
Now, how would I do it so if it has more days then nights in the sentence, it would output day?
 
@Michael I can't see your pastebin link but that savechanges method is fine i guess
you might want to change the name to avoid confusion
 
@Failsafe here it is:

public static class ContactDataAccess
    {
        public static int InsertContact(Contact c)
        {
            using(LitTrackContext context = new LitTrackContext())
            {
                context.Contacts.Add(c);
                return context.SaveChanges();
            }
        }

        public static int UpdateContact(Contact c)
        {
            using (LitTrackContext context = new LitTrackContext())
            {
                context.Entry(c).State = EntityState.Modified;
 
You may want to look into the concept of using the UoW as it is.
Because that is a terrible design.
 
What is the confusion with save changes?
@RoelvanUden Ive looked into it. I know what it is
 
1:53 PM
@kolton would need to do some recursive loops to get them all by indexof
 
@juanvan Can you show me how?
 
@Michael Then you must realize that making repositories like this is a terrible, terrible idea. Even more so considering you're ToList'ing entire tables.
 
@Failsafe so im not going to run into any weirdness by extracting it to this static class
 
user47589
good morning everypony
 
@Michael You can do whatever you want, but as long as your DAL is using those methods
 
1:55 PM
@RoelvanUden You make Repositories to go along side with UoW anyways?
 
(no pony replied)
 
you can write your own middleware or business layer or whatever
@Amy i don't identify as pony-kin
it's really up to you how you want to architect your layers
You need to think of entity as your DAL
 
@Michael No you don't.
 
@RoelvanUden and what do you mean in ToListing entire tables? maybe I need to
 
@kolton I was incorrect, they did it with an extension method
19
Q: Finding ALL positions of a substring in a large string in C#

caesayI have a large string I need to parse, and I need to find all the instances of extract"(me,i-have lots. of]punctuation, and store them to a list. So say this piece of string was in the beginning and middle of the larger string, both of them would be found, and their indexes would be added to th...

 
1:57 PM
Thanks! :D
 
@Michael public static List<Contact> GetContacts() what if you have a million contacts? Boom You serialize all of them. Then you just want to show 10 on a page. You still have to serialize all million of them.
 
Good luck!
 
@RoelvanUden but what If I needed all of them?
 
@RoelvanUden I think it's for a school project
 
@Michael In a UoW you'd just expose an IQueryable that enables you compose the query it fires of to the database down the line, including the eventual limit and paging constraints, very efficiently. Repositories can do that, somewhat, too, but not like you did it. It's terrible to ToList anything.
 
1:58 PM
is it?
 
@Failsafe I'd flunk that student that didn't consider it.
 
@Failsafe no its for an actual company program
 
Even more so. Don't add to the pile of shit that exists today. Write good code.
 
@Michael Then make a return type IQueryable<Contacts>
yea what @RoelvanUden said
 
@Failsafe @RoelvanUden If I wanted to limit it.. I could simply make a method to do that in my repository?
 
1:59 PM
Oh great, let's make a method for every fucking thing you come up with.
 

« first day (1916 days earlier)      last day (3035 days later) »