Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. .NET (Core and Framework)
  4. what is tuple in mvc

what is tuple in mvc

Scheduled Pinned Locked Moved .NET (Core and Framework)
questionasp-netarchitecture
4 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    Anil Sharma1983
    wrote on last edited by
    #1

    which one is use tuple or out varaible . which is best?

    P L 2 Replies Last reply
    0
    • A Anil Sharma1983

      which one is use tuple or out varaible . which is best?

      P Offline
      P Offline
      Pete OHanlon
      wrote on last edited by
      #2

      If you are unsure about what a tuple is, I wrote a brief guide for Pluralsight last year, https://www.pluralsight.com/guides/returning-consuming-tuples[^]. Something to consider if you use async/await, you can't use out with your parameters but you can return a tuple as part of the Task signature.

      Advanced TypeScript Programming Projects

      1 Reply Last reply
      0
      • A Anil Sharma1983

        which one is use tuple or out varaible . which is best?

        L Offline
        L Offline
        Lost User
        wrote on last edited by
        #3

        If one were "best", there's no reason to keep it around in the framework. You can also use tuples as out variables, which makes your question unclear to me. Can you give us two examples of what you are trying to compare?

        Bastard Programmer from Hell :suss: If you can't read my code, try converting it here[^] "If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.

        S 1 Reply Last reply
        0
        • L Lost User

          If one were "best", there's no reason to keep it around in the framework. You can also use tuples as out variables, which makes your question unclear to me. Can you give us two examples of what you are trying to compare?

          Bastard Programmer from Hell :suss: If you can't read my code, try converting it here[^] "If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.

          S Offline
          S Offline
          Sherin_Mathew
          wrote on last edited by
          #4

          So Tuple is a good thing. It is very useful in scenarios where you need to return multiple values from a method but do not intend to create a dedicated DTO for that sole purpose. It is not of structure type either which means it is passed by reference. I created 2 methods in my controller for testing Tuple - one for Get and other for Post.

          [HttpGet]
          public ActionResult TestTuple()
          {
          Tuple t = new Tuple("test", 123);
          return View(t);
          }

              \[HttpPost\]
              public ActionResult TestTuple(Tuple tuple)
              {
                  return new EmptyResult();
              }
          

          The view part is straightforward:

          @model Tuple
          @{
          ViewBag.Title = "TestTuple";
          }

          @Html.BeginForm("TestTuple", "Home", FormMethod.Post){

          @Html.EditorFor(m => m);  
          
          input type="submit" value="Test Tuple"/
          

          }

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups