|
Hi
Am i ask a hard question about 4hours ago.
|
|
|
|
|
Your question is indeed tough. You have to wait patiently for an answer by somebody who knows the answer.
|
|
|
|
|
The reason you did not get an answer is because
a) It was a repost.
b) Your original was replied to, and you reposted last time
http://www.codeproject.com/Messages/3302834/Re-backup-database.aspx[^]
c) There are many examples on CP about to achieve what you want to achieve.
CCC solved so far: 2 (including a Hard One!)
37!?!! - Randall, Clerks
|
|
|
|
|
My question was changed.
I asked that how can i backup from database.
I got my answer and check it when my database attach to microsoft sql.
but it is necessary for me to use SQLEXPRESS and that way doesn't work when i add my database to SQLEXPRESS and detach from microsoft sql.
I explain more about 4 hours ago.
If somebody know the answer please help me.
|
|
|
|
|
Does shouting and hassling people work in your company? Because in all the ones I've worked in, it just gets peoples backs up, and (certainly with me) reduces the amount of help given to the minimum they can get away with. Just thought I'd mention it...
All those who believe in psycho kinesis, raise my hand.
|
|
|
|
|
please !
I don't think that i'm shouting or... .
I thought that i used wrong sentence or wrong structure because my first language is not english.
but if i told in bad way , i'm sorry.
|
|
|
|
|
using UPPER-CASE is equivalent to shouting.
|
|
|
|
|
REALLY? I WAS WONDERING WHY MY FRIENDS WENT DEAF WHEN I TURNED MY SCREEN-READER ON
[edit] Never mind, that sounded funnier in my mind.
modified on Monday, December 14, 2009 3:58 PM
|
|
|
|
|
|
Hello,
I'd like to create an array, and have it contain two items (two-dimensional) of two different types.
I believe the best way to do this is create my own type, however, I'm unsure how to handle the need for an array.
For instance, I want to create something that will take in:
SnapShot[i] = ( DateTime DateTime.Now, Int Size );
How can this be done?
Thanks,
Matt
|
|
|
|
|
Why not use a Dictionary?[^]
All those who believe in psycho kinesis, raise my hand.
|
|
|
|
|
Thanks!
This will work for two items.
What can I do if I want to store more items?
Thanks,
Matt
|
|
|
|
|
Then I would create a class to hold the info, and either use a Dictionary or hold it in a List<T>. You get the flexibility of the array, but without the need to specify the initial size .
All those who believe in psycho kinesis, raise my hand.
|
|
|
|
|
I'd suggest creating a SnapShotInformation class with Date and Size properties.
You can then maintain a List<SnapShotInformation> . This has the advantage of being more maintainable and the size of the list is dynamic (ie you can add more items to is and it will resize).
CCC solved so far: 2 (including a Hard One!)
37!?!! - Randall, Clerks
|
|
|
|
|
why Class? Shouldn't struct be enough?
I Would use struct instead class. Because you do not need to hold any Function only data
|
|
|
|
|
Saksida Bojan wrote: I Would use struct instead class. Because you do not need to hold any Function only data
It is correct in C++ but not in C#. A struct in C++ is mainly used for POD types and in C#, you hardly write structs. You write it only when you need value semantics or you need to communicate with legacy APIs.
Best wishes,
Navaneeth
|
|
|
|
|
Is there performance drop? I use a lot of Struct in some of mine programs when I needed to hold a lot of Data structure within array (Not using PInvoke or accessing COM object). Is it better to use struct or class?
|
|
|
|
|
You might, under certain circumstances use more memory.
See
http://msdn.microsoft.com/en-us/library/ah19swz4(VS.71).aspx[^]
The things to note are (Quotes directly from above):
1) Struct are value types. Classes are reference types.
2) Structs have no inheritence (other than object).
3) "The struct type is suitable for representing lightweight objects such as Point [e.g. a Cartesian Co-ordinate]"
4) "Unless you need reference type semantics, a class that is smaller than 16 bytes may be more efficiently handled by the system as a struct."
C# is very different to c++ in this matter, I've been developing C# for about 8 years now, and have never needed a struct (though I have used them from 3rd party stuff).
CCC solved so far: 2 (including a Hard One!)
37!?!! - Randall, Clerks
|
|
|
|
|
Is there a performance hit when utilizing a List<class> versus a class[array] (and dynamically sizing this array)?
|
|
|
|
|
Both are held on the heap, so I don't think there won't be much of a performance hit, however if performance is an issue, you could benchmark for yourself.
Generally, IMO, unless you have massive arrays or massive objects performance has never been a worry and even if this is the case good design normally mitigates againt this. Modern machines are fast and have plenty of memory (even if this is restricted by the .net framework) so code readabilty is more of a factor in my experience (this would definately go down with an array that needs resizing). I'm not saying that performance shouldn't be considered, I just think that getting clean code first is better, then run the optimizers over the code, and if you see any bottlenecks really work at those, optimizing too soon (which often equals unecessarilty) really wrecks good code.
Additionally, if the array is frequently resized, this can use up resources as the array is copied and re-sized (and hence my benchmarking suggestion above).
CCC solved so far: 2 (including a Hard One!)
37!?!! - Randall, Clerks
|
|
|
|
|
I agree with your ideology. Thanks for explaining.
When an array is re-sized, the data is actually copied/recreated? Are you sure about this?
|
|
|
|
|
Due to the way arrays are implemented they cannot directly resized.
Array.Resize[^] provides resize functionality, but it actually does a copy underneath (as if you created an array of the new size and copied the items across) so the array instance actually changes.
CCC solved so far: 2 (including a Hard One!)
37!?!! - Randall, Clerks
|
|
|
|
|
Thanks for your reply.
This hit on performance (array.resize()) is less than the (probable) lower performance of a List<>? However, if array.resize() was never called, an array would be more optimal?
|
|
|
|
|
No (or not much) to the first, yes to the second. It really depends upon what you are doing to determine which is most efficient, and that can only be done through testing. If my memory serves, in earlier versions of the famework (2.0) there was a noticable performance gap between List<T> and T[] . This was closed up in 3.0, so the performances are similar. I could be confusing this with .NET Reflection however
Using the lists is considered good practice as it is easier to use, also these are more widespread so developers are used to seeing the code.
The real answer to your question I suppose is to write the code using List and judge performance from there. If the performance of your code is poor, run a profiler to see if it is the list operations ar e causing it. If so, replace your code with arrays and see what happens.
CCC solved so far: 2 (including a Hard One!)
37!?!! - Randall, Clerks
|
|
|
|
|
arrays in C# are homogeneous, they can't hold different types, unless you declare them to hold a common type (in the extreme: object) which isn't a good idea. Create your own element type and keep it a one-dimensional array; in simple cases you might be well of by using a Dictionary (requires unique keys).
|
|
|
|