Search Results

Search found 2 results on 1 pages for 'edelweiss'.

Page 1/1 | 1 

  • How to use a class's type as the type argument for an inherited collection property in C#

    - by Edelweiss Peimann
    I am trying to create a representation of various types of card that inherit from a generic card class and which all contain references to their owning decks. I tried re-declaring them, as suggested here, but it still won't convert to the specific card type. The code I currently have is as such: public class Deck<T> : List<T> where T : Card { void Shuffle() { throw new NotImplementedException("Shuffle not yet implemented."); } } public class Card { public Deck<Card> OwningDeck { get; set; } } public class FooCard : Card { public Deck<FooCard> OwningDeck { get { return (Deck<FooCard>)base.OwningDeck; } set { OwningDeck = value; } } } The compile-time error I am getting: Error 2 Cannot convert type 'Game.Cards.Deck' to 'Game.Cards.Deck' And a warning suggesting I use a new operator to specify that the hiding is intentional. Would doing so be a violation of convention? Is there a better way? My question to stackoverflow is this: Can what I am trying to do be done elegantly in the .NET type system? If so, can some examples be provided?

    Read the article

  • Redirect in codeigniter after login

    - by edelweiss
    Trying to do a redirect after a successful login. The login info is sent using ajax to the controller. My controller code as below public function login_controller_function() { $this->load->model('login_model'); if ($this->input->is_ajax_request()) { $user_name=$this->input->post('username'); $user_password = $this->input->post('password'); $this->load->helper('url'); $result = $this->login_model->verify_user($user_name,$user_password); // echo 'user_logged_in'; if(strcmp($result,'user_logged_in')==0) { redirect('welcome'); } } } But it is not working at all. Anyone knows whats wrong? Hi my html as requested. i am using twitter bootstrap as well <li class="divider-vertical"></li> <li><a href="#" id="login_btn">Login</a></li> <li><a href="<?php echo base_url('register'); ?>">Register</a></li> for the buttons so when i click the login button, a modal window will appear and ask for login info. so when i click on the login button, my js code will send an ajax request my js code as below /*Attempt register user jquery ajax*/ $('#login').click(function(){ var user_name = $('#loginHere').find('#user_name').val(); var user_password = $('#loginHere').find('#login_pwd').val(); if(user_name==""||user_password=="") return; var login_data = { username:user_name, password:user_password}; $.ajax({ type: "POST", dataType: "json", async: false, url:"login_register/login_controller_function", data: login_data, success: function(data) { if(data.login) { alert(data.redirect); window.location.replace(data.redirect); } else if(!data.login) { alert('data login not true'); } }, error:function(data){ alert('ajax error'); } }); }); });

    Read the article

1