Jump to content
Xtreme .Net Talk

PlausiblyDamp

Administrators
  • Posts

    7016
  • Joined

  • Last visited

Everything posted by PlausiblyDamp

  1. If the collection is going to go out of scope then I would just leave it to the GC entirely, otherwise setting the variable to null will allow the GC to collect it the next time it kicks in.
  2. If you create a variable of type Process it has a .WaitForExit property, if this is true it waits till the application has exited before continuing
  3. I would open a connection when I need it and close it as soon as I have finished, this lets .Net handle things like connection pooling more effectively. Keeping connections open 'in case I need it later' is usually more of a performance hit than opening them as and when you need them.
  4. Each class could simply call the .GetCities method of the objects it contains to build the list it returns without needing to duplicate the code. The big problem with detectingthe object type at runtie is maintaining the code, if you add a new class that also needs to return a llst of cities you would have to go back and revise your GetCities(o as object) method to include checks for the new class, plus the testing etc involved. Using an interface you add the new class without having to revise any of the existing logic.
  5. If you have separate classes defined for each of these objects then you should define a standard interface that each of the other classes implements, and this would provide a method for returning a list of cities Public Interface ICityProvider Function GetCities() As ArrayList 'use whatever collection type End Interface Public Class World Implements ICityProvider Public Function GetCities() As System.Collections.ArrayList Implements ICityProvider.GetCities Return New ArrayList 'really return a list of cities for a world here End Function End Class Public Class County Implements ICityProvider Public Function GetCities() As System.Collections.ArrayList Implements ICityProvider.GetCities Return New ArrayList 'really return a list of cities for a County End Function End Class 'repeat for each of your other classes each of the individual classes would need to provide it's own implementation for how to return a list of cities. You could then use this interface in your GetAllCities method like so: Private _Cities As CityCollection Private Sub GetAllCities(ByVal O As ICityProvider) _Cities.Add(O.GetCities) End Sub the only thing you would need to do was make sure each of the other classes (World, State, County etc) return a valid list of cities.
  6. Could we? Missed that one, then again an MSDN subscription is a wonderful thing... Pity they only have the professional edition currently available.
  7. I would always use stored procs if the DB supported them and parameterised queries otherwise. Parameters / arguments should always be validated at every public entrypoint (i.e. each layer in your infrastructure) to reduce the chance of exploits etc. Rather than lots of explicit coding I would usually create a DataAccess layer to encapsulate the db specific stuff (either write my own or more likely go to http://www.microsoft.com/patterns and look at either the DataApplication block or the EnterpriseLibrary).
  8. As a general tool autoruns from http://www.sysinternals.com is excellent for showing exactly what is being launched on startup.
  9. Select Case only works with the basic data types provided by .Net hence the limitation. As to which way is better I would probably tend to neither, although without knowing more about the objects in question it's hard to give a definitive answer. Normally some form of polymorphism (Inheritance or Interface implementation) would be a good tool to apply here - but again without knowing exactly what kind of things you would be doing to the objects it's hard to say. If possible could you give an example of what you would be doing - even if it is only using the example of fruit you gave abouve.
  10. You should be able to assign a version to yuor application through the assemblyinfo.cs file that is part of the project, or if you are not using VS then search MSDN for the AssemblyVersion attribute. You can get a string representation of the version number by calling Application.ProductVersion or a more detailed bit of information by calling System.Reflection.Assembly.GetExecutingAssembly().GetName.Version
  11. Assign the value to the textbox in the click event.
  12. What actually happens with the above code? isn't really giving us enough information to be able to trouble shoot the problem...
  13. What is the contents of txtEvDate?
  14. The Page_Load fires before the Button_Click event, you are only assigning the string to the session after it has run the page_load event.
  15. http://www.xtremedotnettalk.com/showthread.php?t=93547 shows how to do simple UITypeEditor.
  16. The class, or a method of the class, could return an array or a collection which could be used for the datasource.
  17. Are you sure the timer even is firing when the service is running?
  18. The GC is lazy by design and will take as much memory as it can, if there is nothing else using the system why shouldn't it keep hold of the memory? Until you've profiled the system and tracked where the memory is being used though it is all speculation...
  19. Clone just creates a shallow copy of the array (a bit like assigning a reference to another variable). IIRC there is an IClonable (or similar) interface you could make your Square class implement, search MSDN and you should get some examples on it.
  20. Any chance you could post the code you are using?
  21. CLRProfiler is your friend here. How much memory does the system in question have installed? Have you tried this on a machine with a lower amount of memory? Have you been testing this single user or multi user?
  22. You may want to also investigate web services as an alternate to remoting as this removes the client side requirements and doesn't impose some of the strange restrictions that remoting does.
  23. Probably the easiest way is to serialize your class to a memory stream and then deserialize it back into a new array variable.
  24. Could you not put a div element on the page and apply the positioning to it and then have it contain your control(s)
  25. Arrays themselves are reference types, hence the problems you were having in the first case as a, b and would all point to the same memory location. The array.CopyTo will copy the elements from one array to another, however if the array is an array of classes (reference types) then the array just contains pointers to the objects in memory; copying the array will copy the pointers not what the pointers point to!
×
×
  • Create New...