Register for your free account! | Forgot your password?

Go Back   elitepvpers > MMORPGs > Conquer Online 2 > CO2 Private Server
You last visited: Today at 21:33

  • Please register to post and access all features, it's quick, easy and FREE!

Advertisement



Get item by id in inventory.

Discussion on Get item by id in inventory. within the CO2 Private Server forum part of the Conquer Online 2 category.

Closed Thread
 
Old   #1
 
elite*gold: 0
Join Date: May 2011
Posts: 1,769
Received Thanks: 756
Get item by id in inventory.

This is how I do it in my source.
Is it a fine way to do it?
Code:
        public Item GetItemInInventoryByID(uint ID)
        {
            var ret = from item
                      in this.Inventory
                      where item.ID == ID
                      select item;
            foreach (Item retitem in ret)
                return retitem;

            return null;
        }
BaussHacker is offline  
Old 10/05/2011, 11:18   #2


 
Korvacs's Avatar
 
elite*gold: 20
Join Date: Mar 2006
Posts: 6,126
Received Thanks: 2,518
What the hell kind of messed up method is that.......

I assume this is a troll?

You use linq to query the Inventory object, then loop through your results to return a single item or return null?

Really??

Bad Bauss, BAD!
Korvacs is offline  
Thanks
1 User
Old 10/05/2011, 11:25   #3
 
elite*gold: 0
Join Date: May 2011
Posts: 1,769
Received Thanks: 756
Ohh I didn't thought of it like that >< Close this xD
BaussHacker is offline  
Old 10/05/2011, 11:28   #4
 
elite*gold: 0
Join Date: Oct 2009
Posts: 768
Received Thanks: 550
Code:
 public Item GetItemInInventoryByID(uint ID)
        {
            foreach(var item in this.Inventory)
                        if(item.ID == ID)
                                    return item;
            return null;
        }
Why would you use a double loop when you can do it only with one? LINQ will get you more than 1 item, which means you can also count in creating a enumerable<> and adding the items in that list, then return it on which you loop and get the first element?

Why do you even bother using LINQ
-impulse- is offline  
Thanks
1 User
Old 10/05/2011, 11:30   #5
 
elite*gold: 0
Join Date: May 2011
Posts: 1,769
Received Thanks: 756
Just close this, I feel bad now =[ LOOL
BaussHacker is offline  
Old 10/05/2011, 11:34   #6


 
Korvacs's Avatar
 
elite*gold: 20
Join Date: Mar 2006
Posts: 6,126
Received Thanks: 2,518
Quote:
Originally Posted by BaussHacker View Post
Just close this, I feel bad now =[ LOOL
Korvacs is offline  
Closed Thread


Similar Threads Similar Threads
S4 Item/Inventory Manager?
09/23/2010 - S4 League - 5 Replies
Is there any working S4 Item manager? And what happened with the S4 Inventory Manager Namo was making?
Item Inventory ?
08/24/2010 - S4 League - 6 Replies
Hi evryone i'm here for ask 1 thing.. Some time ago I heard about this project and I just wanted to ask you something if you nyamocha / XD he really worked with some raffy94thebest grz a greeting Heroez :D
Inventory Expension item
09/16/2009 - Silkroad Online - 12 Replies
Hello There :- ;) Since Gaymax released Inventory Expension item This item will add 32 slots permanently in inventory. but where is the 32 slots ;s there only 16 slot that in page 2 , if i used this item ! it open me Page 3 !!!!! any one can help ??? XD if opining Page 3 i buy i LOL
Inventory Slots ;* By item mall
08/29/2009 - Silkroad Online - 12 Replies
http://images.orkut.com/orkut/photos/OgAAAOKFWiX-d iHh4040yI-uR5R_mK57_gQ3o_20uGvFmCtMSTWQIXZw44yc5tV S4T269cWDGxk3qubuiBSHGeV284YAm1T1UPD9klWV2b4yOIT28 BbieVJLqHjU.jpg This char dont my, is my friend :P only posted screen shot here
[Help] Add an item to char inventory/bag
04/15/2009 - Dekaron Private Server - 3 Replies
Can i do this? Need help:D



All times are GMT +1. The time now is 21:38.


Powered by vBulletin®
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Terms of Service | Abuse
Copyright ©2025 elitepvpers All Rights Reserved.