|
Tridip Bhattacharjee wrote: 1) i just like to know when i will run my program then who call the static main() function Windows. It loads the assembly, looks for an entrypoint. That your "main" method. To be more specific, the .NET runtime would do that.
Tridip Bhattacharjee wrote: 2) when employee class instance will be created then how memory will be allocated for this class? Some memory will already have been allocated once the assembly is loaded. Once you create an object of that class, it'll need to allocate memory for those fields (not for the methods). Those fields are either valuetypes (full list of their sizes on MSDN[^]) or Reference types (pointers). Unless those point to an object, their memory-allocation will be limited to space for that pointer.
Tridip Bhattacharjee wrote: 3) where this variable will store in heap or stack ?
Being classmembers, heap.
Six important .NET concepts: Stack, heap, value types, reference types, boxing, and unboxing[^]
Tridip Bhattacharjee wrote: 4) where _local variable will be store when calculatevalue will be called ? Stack, as all local declared value-types will be.
Tridip Bhattacharjee wrote: 5) the important things is where data is stored when we assign data to variable. in stack or heap ?
Someone is overstating the importance between stack and heap. I feel a truckload of .ToArray conversions coming up for "performance reasons". Valuetypes to the stack, pointers on the stack pointing to lots of bytes in the heap. That's for the executing method; not for every class loaded in the framework.
Tridip Bhattacharjee wrote: Name="Hello" or Salary=5000 where Hello & 5000
Hello is a string and thus a reference type, salary an integer and a value-type. The first on the heap, second on the stack. Combining them like that would either result in an exception (C#), or a new string (VB) which would be a reference type again.
Tridip Bhattacharjee wrote: 6) where static variable is stored declared in class?
Heap, until it's used.
Tridip Bhattacharjee wrote: 7) static class load into memory when program just run even if i do not call or use them ?
Yes/no. Everything in your assembly will use memory, since it'll be added to the list of "known types loaded". No, it will not run it's static constructor nor allocate memory for it's members until it's first use, as is documented on MSDN.
Tridip Bhattacharjee wrote: i heard that memory is allocated when we create instance of non-static class. so in case of static class we can not create instance so how they load into memory.
By calling it's constructor[^].
Now here are my questions; why did the interface disappear from this example? And why isn't there a reference to a struct? Would an object in a struct be considered a value-type or a reference-type? What about static structs?
Here's some reading;
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
thanks for clear answer. i heard that all local variable store on stack. one more question is that if local variable is ref type declared in function and when function will be called then where local variable ref will be stored....in stack or heap. ?
two good question here u highlighted. those are
a) Would an object in a struct be considered a value-type or a reference-type?
b) What about static structs?
c) interface is contract so at all any memory is allocated for interface ?
if possible give answer for that two question.
tbhattacharjee
|
|
|
|
|
Tridip Bhattacharjee wrote: i heard that all local variable store on stack.
You heard wrong. One can declare a string, 1 GB in size, as a local variable. Your stack ain't 1 GB.
Tridip Bhattacharjee wrote: one more question is that if local variable is ref type declared in function and when function will be called then where local variable ref will be stored....in stack or heap. ?
It's a reference. Where would you guess it'd be stored?
Tridip Bhattacharjee wrote: a) Would an object in a struct be considered a value-type or a reference-type?
The struct is a value-type, the object a reference.
Tridip Bhattacharjee wrote: b) What about static structs?
There is no such thing as a static struct. Special case, was a trick question and searching the answer might be fun
Tridip Bhattacharjee wrote: c) interface is contract so at all any memory is allocated for interface ?
Seems I already answered two, this one is yours (and has been answered before )
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
"It just doesn't matter." -- Meat Balls
|
|
|
|
|
|
So for instance, my laptop is connected to a projector via VGA cable, is there a way to control when I want to display the laptop's desktop in the projector? I'm creating an interface in C# wherein if I click a specific button, the projector will display the laptop's desktop. Basically it acts like the Win + P function of windows.
Thank you for any help!
|
|
|
|
|
Haven't tried it myself, but these might help:
Complete Guide on How To Turn A Monitor On/Off/Standby[^]
Multi-monitor programming in C#[^]
If nothing else works, there is always the simple solution: have a neutral background to your desktop (an image of the presentation name, and your contact details perhaps) and then show a form on the second monitor (maximized) when you want the projector to display. Minimize it when you don't.
The universe is composed of electrons, neutrons, protons and......morons. (ThePhantomUpvoter)
|
|
|
|
|
Hi can you please help me a number slider puzzle solver code is developed with c # is a 3 * 3 and 4 * 4 with 4 types of algorithms that can be compared with each other (in the discussion of artificial intelligence). Thank you, Jebreil644
|
|
|
|
|
You have chosen quite a question to pose here. Looking at Neural NEtworrks might be one solution, other might be looking at simular articles posted here on the codeproject site.
|
|
|
|
|
So, what's the actual question?
By the way, sliding puzzles are conventionally solved with A*[^], with various different heuristics, such as "sum of manhattan distances".
|
|
|
|
|
Hi
I want to simulate Windows Explorer by C# and I write the code,and now I want to add Back and Forward button,the project see the path but I do not know how to go Back or Forward?
thanks for your help
Baharan20
|
|
|
|
|
|
Thanks
I have seen this code Before
But I don't Understand the code
|
|
|
|
|
baharan20 wrote: I want to simulate Windows Explorer by C# and I write the code,and now I want to add Back and Forward button,the project see the path but I do not know how to go Back or Forward?
Your application will have a "current directory" that it's showing?
Add it to a List every time it changes. Implement the "Back" button by fetching the path from that list and displaying that. That concept should make implementing the "Forward" button easy
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
Hi everybody!
I'm learning about FEC for WSN. If you have OSPF code or FEC code (ex: RS code, CRC,...)in WSN, you can send to me . Thanks!
|
|
|
|
|
Wow, so many acronyms, all saying the same thing. Can you please do my work for me?
|
|
|
|
|
Hi Arif_Khan
You are here: Microsoft .Net > C# - Image Processing > Histogram Equalization
this up location folder not found, please again update this folder project for download
|
|
|
|
|
Hi Arif_Khan
You are here: Microsoft .Net > C# - Image Processing > Histogram Equalization
this up location folder not found, please again update this folder project for download
|
|
|
|
|
If you have a problem or question with an aritcle, post it in the forum at the bottom of that article.
|
|
|
|
|
Hi
I have a WPF list View and It has some contents say.
Row1, Row 2 , Row 3, Row 4, Row 5..
Also I have 2 arrows in application which moves the item in the list view Next and Previous.
When I shift select Row 3 to Row 5 all 3 gets selected
Now I click Next and the selection selects Row 4, as we consider first click as the recent item and Next should move the selection to Row 4..
Until this all works fine.
But now when I do shift selection from Row 4 to Row 5...
Row 3, Row 4, Row 5 are getting selected..actual result should have been only Row 4 and Row 5..
I have tried many different ways ...but could not find a proper solution..Looks like items are not cleared from selection set of ListView..Any help would be really appreciated
|
|
|
|
|
Are you clearing the selection set on the click of your button?
Use the best guess
|
|
|
|
|
Thanks Richard
But I am not clearing Selection set on click of Next/Previous button.
But when I click Next the UI shows one item highlighted and after that when I do shift selection ...It also selects the previous one along with the current ones...
How can it remember the selection of Previous action when on Next click the SelectedItems count is One..and after shift selection It gets the old one back again?
|
|
|
|
|
Since we have no idea what your Next button does, it is impossible to say what is happening.
Use the best guess
|
|
|
|
|
Hi Richard,
I think selection is behaving indifferently after Next/Previous operation ...Let me Dig more into it and get back to you.
Thanks
Rakesh
|
|
|
|
|
Hi Richard,
I just tried a sample where I have a ListView and Two Buttons Next and Previous....
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
lvw1.Items.Add("Row1");
lvw1.Items.Add("Row2");
lvw1.Items.Add("Row3");
lvw1.Items.Add("Row4");
lvw1.Items.Add("Row5");
lvw1.Items.Add("Row6");
lvw1.Items.Add("Row7");
lvw1.SelectedIndex = 0;
}
private void Next_Click(object sender, RoutedEventArgs e)
{
lvw1.SelectedIndex = lvw1.SelectedIndex + 1;
}
private void Previous_Click(object sender, RoutedEventArgs e)
{
lvw1.SelectedIndex = lvw1.SelectedIndex - 1;
}
}
I make first item as selected by default.
And then on Next and Previous I just move the selected index according to the action.
Here also we can observe that when I do Mouse down and select an item and then do shift select..everything is good. for example ..Mouse down on Row2 and then Shift select Row 4.
Row2,Row3,Row4 gets selected..All good.
Now I do click on Next Row3 gets selected...Now when I do Shift Select Row 5
Row2,Row3,Row4,Row5 gets selected. which is wrong as the expected selection should have been Row3,Row4,Row5.
Now I am confused whether this is the existing behavior of WPF listview or is there a workaround for the above...
Also if we keep doing Next and then do shift selection after several Next operation I find that shift selection keeps all the selections in memory and selects bunch of rows..
Any help would be appreciated.Need this feature shipped in a week
Thanks
Rakesh
|
|
|
|