locked
How can i dynamically assign a value in the using of a cs file ? RRS feed

  • Question

  • User1253338400 posted

    Hi 

    Can i do the following ? I would like to set the $(ProjectName) as soon as the file is first loaded. It is a class that wont change.

    Reason is because i need to create multiple of these but each will have a different name as the project. lets says the project was called Project1 then I would hvae to add the using for that via ctrl +.  if it was Project2 the same etc .

    This comes off a template that I have created and every time i need to create a project i just use the template , but i couldnt find a way to set the using as the same name I give the project when creaating

    using System;
    using System.Collections.Generic;
    using System.Text;
    using System.Threading.Tasks;

    using $(ProjectName)

    namespace ViewModel
    {
        etc etc

    thanks

    Thursday, July 3, 2014 3:46 AM

Answers

  • User-1454326058 posted

    Hi robby32,

    As PANkaj9999 said that you could use the same namespace. After that you could use using [namespace].

    For the different class name, you could have an interface, then the classes are implement this interface.

    IMyInterfase instance1=new Class1();

    Thanks

    Best Regards

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, July 4, 2014 5:17 AM

All replies

  • User982025680 posted

    You should use SAME namespace for all project. 

    Thursday, July 3, 2014 8:08 AM
  • User-1454326058 posted

    Hi robby32,

    As PANkaj9999 said that you could use the same namespace. After that you could use using [namespace].

    For the different class name, you could have an interface, then the classes are implement this interface.

    IMyInterfase instance1=new Class1();

    Thanks

    Best Regards

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, July 4, 2014 5:17 AM
  • User1253338400 posted

    Thanks works

    Monday, July 7, 2014 2:22 AM