Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Recent content by jmcpher

  1. jmcpher

    FileIOPermission denied when using WebRequest

    The DLL is not running on the server, it is running on the client. I apparently forgot to add that part. "Programming is like sex, one mistake and you have to support it forever." John johnmc@mvmills.com
  2. jmcpher

    FileIOPermission denied when using WebRequest

    I am creating a C# dll for use on our intranet, so there are some security issues. I have given the web unrestricted File IO permissions. This function works fine: [FileIOPermission(SecurityAction.Assert, Unrestricted = true)] protected void LoadIt (string path) { XmlDocument doc = new...
  3. jmcpher

    static interface methods

    The two options that I can think of for what you have described are: 1. Create one class with several static functions (one for each class of access), then pass variables to that function to determine eactly what to do. 2. Use a static member variable (Singleton like you suggested) to hold...
  4. jmcpher

    static interface methods

    An interface is a contract with the compiler that your objects (not your Types!) will be able to handle a function call through that interface. A static method is called with a Type, not an object, and you cannot get an interface handle on a Type. Basically, what you claim you want is not...
  5. jmcpher

    Specified cast is not valid?

    The Value property returns an object, and that object might not actually be an int. Convert.To*() will take an object, cast it to an IConvertible, and then call its To* function. So basically Convert does the cast by asking the object to please cast itself. "Programming is like sex, one...
  6. jmcpher

    Specified cast is not valid?

    Try passing your value to Convert.ToInt32(), a cast may not always work the way you think it should. "Programming is like sex, one mistake and you have to support it forever." John johnmc@mvmills.com
  7. jmcpher

    Return type inheritance

    Thanks Cheiron, that is exactly what I was looking for, and although it isn't as elegant as having the compiler handle it for you (which pretty much any language but C is all about), it still achieves the desired result. Unfortunately I decided to change the names of the functions in my...
  8. jmcpher

    A little theory please: passing objects to functions

    Not to step on your toes obislavu, but C# doesn't work that way. It is much more like Java than C++ in terms of passing variables to functions. In C# their are two types of types, object (reference, etc) types (string, DataTable, etc) and value types (int, float, any struct, etc). When an...
  9. jmcpher

    Converting string to a Color ?

    The following function should do what you would like in a very generic way: object StringToEnum (string val) { int last_dot = val.LastIndexOf('.'); if (last_dot <= 0 || last_dot == val.Length - 1) throw new ArgumentException(&quot;Not a valid enumeration value.&quot...
  10. jmcpher

    C# and C++ together... is it possible?

    Yes, it is very possible and in fact not very hard. Once you create your C# project, add your C++ ActiveX code as a reference by right-clicking References, going to the COM tab, and then browsing for your component. This will automagically create an Interop.whatever.dll so that your C# can...
  11. jmcpher

    Building Dynamic Code

    So you want something like: [] File 1 [] File 2 [] File 3 ... or: [] Text from file 1 that may go on for many lines... [] Text from file 2 that may go on for many lines... [] Text from file 3 that may go on for many lines... ... If so, this can be done fairly easily, and you don't need to...
  12. jmcpher

    Return type inheritance

    I have the following setup: interface A { ... } interface B { A foo (); } class C : A { ... } class D : B { C foo (); } So basically, I want class D to return a specific type (C) while at the same time implementing interface B which wants a more general type returned (A). One...
  13. jmcpher

    Compiler can't find method

    You can also inline your casting like so: ((A) q.pop()).somethingInA(); or you can use Reflection like so: object obj = q.pop(); obj.getType().InvokeMember(&quot;somethingInA&quot;, BindingFlags.InvokeMethod, null, obj, null); but it is slower to use Reflection than casting...
  14. jmcpher

    Copying an enum

    I was also doubtful, as I have never seen a language or compiler support anything like copying an enum. I just did it using the way I did in the first post, but since the enums I wanted to copy only had a few members, it wasn't bad. &quot;Programming is like sex, one mistake and you have to...
  15. jmcpher

    Copying an enum

    Does anyone know if there is an easy way to copy an enum? I know [ok, think] I could do something like: enum MyEnum { One = TheirEnum.One, Two = TheirEnum.Two, Three = TheirEnum.Three, ... } but I am wondering if a better way exists? &quot;Programming is like sex, one mistake and...

Part and Inventory Search

Back
Top