Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6621673
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T21:17:52+00:00 2026-05-25T21:17:52+00:00

in some project we are using Generics, and we get a lot of lines

  • 0

in some project we are using Generics, and we get a lot of lines like this:

Line<SomeTClass,SomeCClass> myLine =
           (Line<SomeTClass,SomeCClass>)LineFactory.CreateLine(...)

We can declare local alias, with using X = Line<SomeTClass,SomeCClass>.

Then we can write, X myLine = (X)LineFactory.CreateLine(...).

We have a lot a combination of <T,C> but we often use the same. Is it possible de declare the using globally, so that we won’t have to declare the alias in each file?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T21:17:53+00:00Added an answer on May 25, 2026 at 9:17 pm

    No such thing as a global alias. What you can do is use type inference to simplify your declarations:

    var myLine = (Line<SomeTClass, SomeCClass>)LineFactory.CreateLine(...);
    

    and if that’s not specific enough for the inference system, you can make the CreateLine() method generic to enforce it:

    var myLine = LineFactory.CreateLine<Line<SomeTClass, SomeCClass>>(...);
    

    and given the name of the LineFactory type, maybe even simplify it some more:

    var myLine = LineFactory.CreateLine<SomeTClass, SomeCClass>(...);
    

    This last option feels “right” to me in some way I can’t fully articulate. Just in case you need a little help, the method declaration would look like something this:

    public static class LineFactory 
    {
        public static Line<T,C> CreateLine<T,C>(...) { ... }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I succesfully created a project using seam credentials for authentication, but right now some
I need some opinions here. I'm working on a Django project using buildout to
I have a project that using some third-party libraries. My questions is how to
I am currently building my project locally using MVC. The user enters some search
I must integrate some macros in a project which is using a cake-pattern. That
I'm using StringTemplate V4 to generate some HTML code in my project. I need
I'm using seeds.rb to load some dummy data into my project as I develop
I'm using MVC 2 with some Models from a LinqToSql project that I built.
i posted some data using tinymce (in a symfony project).while retrieving back how can
Background I'm adding some features to a project that uses subversion - I'm using

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.