how to add condition in object declaration ? EF -

I would like to do something like this (below)... I don't want to full write out template.title = xxx, template.descrption =xxx etc.

but I can't compile, because condition is not correct. I seems to be I can add the condition like this (lang == "E") ? doctype = "Spot-II: " : doctype = "Spot-IIII " within the declaration

etc...

Does someone know how to get (lang=="E") condition working below?

        foreach (var item in s)
        {
            template = new RSSTemplate()
            {
                title = item.titre,
                description = item.description,
                (lang == "E") ? doctype = "Spot-II: " : doctype = "Spot-IIII "
            };
            t.Add(template);
        }

Answers


Maybe this will work:

  foreach (var item in s) 
    { 
        template = new RSSTemplate() 
        { 
            title = item.titre, 
            description = item.description, 
            doctype = (lang == "E") ? "Spot-II: " : "Spot-IIII " 
        }; 
        t.Add(template); 
    } 

Need Your Help

javascript function not visible? does not get called a second time

javascript ruby-on-rails-4 backbone.js raphael

This may be a pretty newbie question so bear with me. I am tinkering a little with Ruby on Rails 4, Javascript and Raphael. I'm using Backbone too. On my root page I got two buttons, one which rend...

How come my program can connect to a nonexistent website?

python http ironpython

I am new to python and network programming and I am having trouble with a simple program. I am basically opening a connection to a nonexistent website and somehow it seems that the connection succe...

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.