Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

C# - Need to pass variable to a class

Posted on 2012-03-22
6
Medium Priority
?
326 Views
Last Modified: 2012-08-13
I have the below code in an ASP.NET page.  It works fine.  I need to modify it.  I wrote a WCF Service and I need to call that service in the class below.  I know how to do that.

The issue I'm having is I need to pass an ID to the class to be used by my WCF Service.  Any ideas?

    //FILES
    public class FileList
    {
        static FileList()
        {
            getFiles = new List<Files>();
            getFiles.Add(new Files() { FileName = "Test.1zip" });
            getFiles.Add(new Files() { FileName = "Test2.zip" });
            getFiles.Add(new Files() { FileName = "Test3.zip" });
       }
        public static List<Files> getFiles { get; set; }
    }

    public class Files
    {
        public string FileName { get; set; }
    }
0
Comment
Question by:CipherIS
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
6 Comments
 
LVL 20

Accepted Solution

by:
BuggyCoder earned 2000 total points
ID: 37754540
create an operation contract with parameter named ID of your type.
Let's say the service looks like:-
[ServiceContract]
interface IMyService
{
[OperationContract]
string Operation(int ID);
}

public class MyService : IMyService
{
public string Operation(int ID)
{
return ID.ToString();
}
}

//Here is the client Code
using(var proxy=new MyServiceClient())
{
var strRet=proxy.Operation(10);
//Here 10 would be returned
}

Open in new window

0
 
LVL 1

Author Comment

by:CipherIS
ID: 37754556
My WCF is fine.  I just need to pass the ID to the class and use that ID in the class.
0
 
LVL 75

Expert Comment

by:käµfm³d 👽
ID: 37754567
Expose a property or method which takes in a parameter for the information you would like to receive. It's difficult to tell from the code you posted as to the desired result.
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 20

Expert Comment

by:BuggyCoder
ID: 37754602
i have passed ID in the my example and used it in Service Class
0
 
LVL 1

Author Comment

by:CipherIS
ID: 37754733
I've attached my code in a text file.  I put a comment where I need the UserName to be passed.

Please let me know how to resolve this.

Thanks
Pass-UserName-to-AccountList.txt
0
 
LVL 1

Author Comment

by:CipherIS
ID: 37754774
I figured it out.  Thaks for your help
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…

604 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question