Entries:
Comments:
Posts:

Loading User Information from Channel 9

Something went wrong getting user information from Channel 9

Latest Achievement:

Loading User Information from MSDN

Something went wrong getting user information from MSDN

Visual Studio Achievements

Latest Achievement:

Loading Visual Studio Achievements

Something went wrong getting the Visual Studio Achievements

Discussions

punkouter punkouter
  • Acces class properties at runtime in C#

    I'm not sure I understand your question. Can you describe in more details what you are trying to do? If you already have a reference (of FieldInfo) to a particular field in question from the type, you can access that particular field on any instance of your class using that FieldInfo. FieldInfo.SetValue or GetValue requires you to pass the instance of the object of the field you want to set or retrieve.

  • Why cout (c++) is so slow under Vista ?

    Dexter said:
    evildictaitor said:
    *snip*

    cout is itself part of a runtime, the C/C++ runtime (also known as CRT in the Microsoft world). If you were to actually write low level code in C/C++ you'd have to use WriteFile(STD_OUTPUT_HANDLE, ...) on Windows and write(1, ...) on Unix.

    Anyway it's just a matter of defaults. gcc does line buffering by default (as far as I remember) while VC++ does not. You can always add something like this to your main funtion to change the default stdout buffering:

    char buf[1024];
    setvbuf(stdout, buf, _IOLBF, 1024);

    probably it is best to differentiate 'runtime (environment)' (in .NET and Java that would be the VMs) and 'runtime library' (in C++ that is a set of standard library functions). because c/c++ compiles directly to machine language, it does not run on top of any layer other than the physical machine itself.

  • Something you learned in the last 3 months from Ch9?

    a lot of things, but one thing that is most memorable for me, is.... how to answer interview questions. really helped me a lot, and i have a new job starting next month! yay! thanks for the help everyone.

    Smiley

  • .NET Advantages

    amit_trehan wrote:
    
    littleguru wrote:
    So you have a work to do and you give it to other (unpayed) people to do it for you? Nice way to get stuff done

    Should we then implement the ASP.NET application for you too?


    Before coming to this forum, I had collected ample information. I just wanted to validate the info or get some new points.

    And about implementation, people do that too. People who doesn't want to share information this is not the place for them.



    well, maybe littleguru comments was a bit harsh. but, judging from how you asked the question, people can be easily misunderstood you. but then again, not everyone is native english speaker... so please don't take it too personally

    about your question, though. it requires a very broad answer. it may require some MS evangelists to describe the full answer. and your question does implied you want the whole answer. so, nobody really cares to reply it. i cant even think where to begin with... its just so many.

    if you have collected ample informations, then i believe you do know what the advantages of ASP.Net. rather than asking a vague question like that, why don't you asked some points that is maybe still not clear to you. for instance, performance rate or something specific. if you're looking for new points, tell us what you've gotten and what specific things that you wanted to know more about. then maybe someone can help you.

    Smiley

  • Writing my own scanf(), sscanf() and fscanf() functions

    Shining Arcanine wrote:
    1. I have a copy of The C Programming Language, by Brian W. Kernighan and Dennis M. Ritchie. Will I need any other reference materials or should this be sufficient?


    i don't know, i never wrote a Standard C Library before... maybe you shouldn't also. consult with evildictator, maybe he has

    Shining Arcanine wrote:

    1. Will I be violating Brian W. Kernighan's and Dennis M. Ritchie's vision for the scanf(), sscanf() and fscanf() functions if I make whitespace matter inside square brackets?



    actually, i don't really understand this: %[^&]s <-- what does this means?

    if you change the behavior of standard functions that is widely used, then your function will break a lot of codes. worse, your function will behave unexpectedly to the user of the function and to people who read your code. that's not good, right?

    Shining Arcanine wrote:

    1. Is it possible to do things in such a way that I could divert all function calls to scanf(), sscanf() and fscanf() to my own custom functions without affecting the other stdio.h functions or will I have to use different function names?


    well, two function with same signature can't exist in the same namespace. so you'd have to use different names. diverting is not good, see above. however, if you insist in doing it, you can try not linking with the standard library and build your own library. that way your program will be using your custom functions (i dont know if the compiler will let you do that though).


    Shining Arcanine wrote:

    1. If I manage to make robust implementations of scanf(), sscanf() and fscanf(), what will be my options for giving back to the community?


    you mean, with your redefined specs? i'd say... zip. remember, standard c library is arguably one of the most widely reused code in the world. so, if you can't do it with standard library it's most likely (99.999999....%) that you're the one whose not using it correctly.

    when i implement something, one of the rules that i always keep in mind is: 'Don't change the semantic'. the way you propose to change the semantic of those functions just doesn't fit quite well with me.

  • Converting bits and bytes

    ZippyV wrote:
    I looked up the documents the company send me and the implementation guide does show 1 byte for a 4 bits variable. But the specification docs didn't mentioned that.


    it won't make much sense if that was not the case Smiley. however, just to be sure you better check the interface you're interfacing with. usually, with this kind of byte stream interfaces there should be a documentation that have a byte-to-byte mapping on the parameters. if not, then consult with the engineers who built them and kick their a**es for not providing a decent documentations. OR, maybe you can look at sample of use or the original implementation of the procedure.

  • Writing my own scanf(), sscanf() and fscanf() functions

    Dear Sir,

    how about using strtok ()

    Wink

  • .NET Question: Problem with databinding in own custom generic objects.

    hi Richard,
    here's some sample code for you. try it yourself. Wink

            /// <summary>
            /// a simple business object. to circumvent datagridview binding to properties behavior.
            /// (if i use string, datagridview will bind to 'Length' property)
            /// </summary>
            public class BusinessObject
            {
                public String Text { get; set; }

                public BusinessObject(String somestring)
                {
                    Text = somestring;
                }
            }

            /// <summary>
            /// Just to fill out some default data
            /// </summary>
            /// <returns>a list with default data</returns>
            private IList<BusinessObject> CreateBusinessObjects()
            {
                IList<BusinessObject> list = new List<BusinessObject>();
                list.Add(new BusinessObject("one"));
                list.Add(new BusinessObject("two"));
                list.Add(new BusinessObject("three"));
                list.Add(new BusinessObject("four"));
                list.Add(new BusinessObject("five"));
                return list;

            }

            private void Form1_Load(object sender, EventArgs e)
            {
                Sample2();
            }

            /// <summary>
            /// This method shows that the business object six is not shown in the datagridview.
            /// This is because DataGridView doesn't know about the changes on it's underlying data source
            /// </summary>
            private void Sample1()
            {
                IList<BusinessObject> list = CreateBusinessObjects();
               
                dataGridView1.DataSource = list;

                list.Add(new BusinessObject("six"));
            }

            /// <summary>
            /// This method shows that the business object six is not shown in the datagridview.
            /// It seems DataGridView doesn't do rebind on SAME object datasource assignments (for efficiency?)
            /// Look at DataGridView Source code
            /// </summary>
            private void Sample2()
            {
                IList<BusinessObject> list = CreateBusinessObjects();

                dataGridView1.DataSource = list;

                list.Add(new BusinessObject("six"));

                dataGridView1.DataSource = list;
            }

            /// <summary>
            /// This method shows that the business object six is shown in the datagridview.
            /// But this is only partial solution, there is a better solution...
            /// </summary>
            private void Sample3()
            {
                IList<BusinessObject> list = CreateBusinessObjects();

                dataGridView1.DataSource = list;

                list.Add(new BusinessObject("six"));

                dataGridView1.DataSource = null;
                dataGridView1.DataSource = list;

            }

            /// <summary>
            /// This method is the recommended method.
            /// We use a BindingSource to wrap the list. By using this class, DataGridView can receive
            /// advance notifications on events that is exposed by BindingSource. Accessing the list
            /// from the BindingSource wrapper triggers notification to DataGridView and DataGridView
            /// can update itself as necessary.
            /// </summary>
            private void Sample4()
            {
                IList<BusinessObject> list = CreateBusinessObjects();

                BindingSource bindingSource = new BindingSource();
                bindingSource.DataSource = list;

                dataGridView1.DataSource = bindingSource;

                // This is the critical point. Use the BindingSource to update the List
                bindingSource.Add(new BusinessObject("six"));
            }

    by the way...

    OrigamiCar wrote:

    The wierd thing is that if I put a breakpoint on the line after the refresh()...


    Refresh() method is not for refreshing data source or performing rebinding. Refresh() is to update the visual of DataGridView, so it only effect DataGridView display. Refer to the MSDN docs...

    Hope it helps.. 

  • Where do you store single pieces of information?

    Sven Groot wrote:
    Just to be a little more specific, it's just some text displayed on a single page of a website that the site owners will be able to change via the admin interface (it's actually two pieces of text: the version as the user input it and the html formatted version).

    That rules out web.config because I don't want to change that from code (has some nasty side-effects like resetting the application). I could use a flat file though. Such an ExtendedProperties table might be an idea, but the only thing it'd hold for the foreseeable future would be that piece of text.


    database is the way to go sven.

    you can use the ProfileProvider you can use the SetPropertyValues to insert any kind of properties you want the user to have. the data then will get serialized into a field in the profile table in the database and you dont even have to create a table for the text. you can even extend the profile provider to match your needs.

  • Converting bits and bytes

    punkouter wrote:
    

            [StructLayout (LayoutKind.Sequential,Size =11)]



    gaahh... i miscalculated the size,.. suppose to be Size = 10