0

New to C# I am working within the structure of a program called "PageFlex" which has all the structure placed inside of this code below. My main reason for posting this here is to make sure that I properly formatted my script. Please let me know if this looks formatted correctly. Also is there a site just like jsfiddle.net that you can use for C#?

<script language="C#" runat="server">

string GetUserID(Pageflex.Ur.Storefront.Data.StorefrontAPI isini)
{
    return isini.GetValue("SystemProperty", "LoggedOnUserID", null);
}

int GetShoppingCartCount()
{

    Pageflex.Ur.Storefront.Data.StorefrontAPI isini =
       new Pageflex.Ur.Storefront.Data.StorefrontAPI();
    string userID = GetUserID(isini);
    string[] docsInCart = isini.GetListValue("UserListProperty", "DocumentsInShoppingCart", userID);
    return (docsInCart != null) ? docsInCart.Length : 0;
}
int GetShoppingCartTotal()
{
    Pageflex.Ur.Storefront.Data.StorefrontAPI isini =
    new Pageflex.Ur.Storefront.Data.StorefrontAPI();
    string userID = GetUserID(isini);
    string[] docsTotalPrice = isini.GetListValue("DocumentProperty", "DocumentPrice", userID);
     return (docsTotalPrice != null) ? docsTotalPrice.Length : 0;
}
void Page_Load(object sender, EventArgs e)
{
    if (!Page.IsPostBack)
    {
        int documentPrice = GetShoppingCartTotal();
        priceCart.Text = shoppingPrice.ToString();

        int shoppingCount = GetShoppingCartCount();
        numCart.Text = shoppingCount.ToString();
        ItemOrItems.Text = (shoppingCount == 1) ? "item" : "items";
    }
}
</script>
John Saunders
  • 160,644
  • 26
  • 247
  • 397
Cam
  • 1,884
  • 11
  • 24
  • Possible duplicate: http://stackoverflow.com/questions/30101/is-there-an-automatic-code-formatter-for-c – sinelaw Feb 06 '13 at 17:44

2 Answers2

0

Things looks right to me. You may need to declare you methods as public:

 public int GetShoppingCartTotal()
 {
 // logic
 }

but, you may not have to when you're code is at the page level.

pwnyexpress
  • 1,016
  • 7
  • 14
  • Its at pagelevel just didnt want to make people dig.. Thats good at least I am waiting on a response from the programs forums on what I messed up on. one of those values is incorrect. – Cam Feb 06 '13 at 17:55
0

Regarding

Also is there a site just like jsfiddle.net that you can use for C#?

You can always try Ideone (though its not exactly like jsfiddle), its supports ALOT of different languages including C# (Mono).

Norrin
  • 385
  • 2
  • 8